Thanks all... replied once to this, and it went to never never land.

These are all along the same lines... Tim's suggestion is right on the
money as to what I need ( changes in the model code and nowhere
else).  I'll try it out as soon as my DBA modifies the tables, which
is hopefully soon.

On May 24, 5:24 pm, Matt McClanahan <[EMAIL PROTECTED]> wrote:
> On May 24, 2:03 pm, "[EMAIL PROTECTED]"
>
> <[EMAIL PROTECTED]> wrote:
> > To accomplish this we are going to add a 'deleted_flag' to each table,
> > and set it to 0 if it is not deleted, and 1 if it is deleted.
>
> Just as an aside, when I use this approach I find it handy to use a
> date field, 'deletedate' rather than a flag.  This provides the extra
> bit about when an item was deleted, which can sometimes be useful
> later information on.
>
> > Rather than going to every function I am displaying items ( 99% of the
> > time I'm using .filter then some filter ), is there a way to tell it
> > in the model to always append delete_flag=0 to any of the .filter
> > parameters I am passing in, so that only non logically deleted items
> > are returned?  I just thought I'd check before trolling through
> > thousands of lines of code for all of my .filter statements.
>
> What you're probably looking for is a custom model manager that
> replaces the default manager for your models.  Making a custom model
> manager is documented 
> athttp://www.djangoproject.com/documentation/models/custom_managers/
> and the example case (published books) is very similar to what you're
> after.  The only thing that example doesn't do is make the custom
> manager the default.  This is accomplished simply by setting the
> model's 'objects' property to your custom manager.
>
> Bear in mind, however, that there can be side effects to applying a
> filter of this sort by default to all queries made through the
> manager.  For example, since the admin application uses the default
> manager, items which are filtered out will be inaccessible from
> there.  This issue is discussed in ticket #1855.
>
> Matt


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to