Alex Rivera | Logout

Modify default queryset in django

Asked 2010-03-22T17:48:12.227
33

I have added a 'cancelled' field to my model, is there a way to modify the model default query to something like cancelled=False ? without having to modify all my filter/exclude queries ?

Edit
Report

1 Answer

3

You could write custom query manager, but I don't believe this is the right way to go. This would make an implicit, hidden condition for a filter, which would make code unreadable. Remember Zen of Python: Explicit is better than implicit. Detect places, where you need to add cancelled=False and just add this, that's the way you should do this.

answered 2010-03-22T17:57:16.930

Your Answer