Hi Derek, On Sunday 15 January 2017 06:53:10 Derek wrote:
> You don't appear to have understood my question; and I did not see > this particular use case covered in the docs (which is why I asked > it). You also pointed me to the wrong version; in particular > "QuerySet.as_manager()" is not method in 1.6. Take a look at the DahlBookManager example: it filters all books by author Dahl and "limits what is displayed". If you compare it to your code, then you see that the entire MyModelQuerySet class can be deleted and your MyModelManager.get_queryset() method turns into: def get_queryset(self): return super(MyModelManager, self).get_queryset().filter( classification='general' ) Delete method could become something like this: def delete(self): qs = super(MyModelManager, self).get_queryset().filter( code__neq='protected' ) return qs.delete() I'm using a call to super() in delete, so we get access to all objects. Please read the part about the default manager and its dangers before making it the default manager. Last, but certainly not least: if you *only* need this for the admin, then it's better to look at ModelAdmin's list_filter property and/or get_queryset method and the has_delete_permission method. For example: class MyModelAdmin(admin.ModelAdmin): model = MyModel list_filter = ('classification',) def has_delete_permission(self, req, obj): if super(MyModelAdmin, self).has_delete_permission(req, obj): if obj.code != 'protected' : return True return False Note that this doesn't set the default filter to 'general', but it does make filtering transparent (and allows access to objects which are not 'general'). P.S.: The reason I pointed to 1.10 docs is simple: 1.6 is no longer supported by the Django Project and it's documentation has been removed from the site. -- Melvyn Sopacua -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/11651873.cjmEqRYSjg%40devstation. For more options, visit https://groups.google.com/d/optout.