Hello,
I am trying to exclude several categories from a m2m, but when I see the
widget in my form all still appear, I put the code that I execute when I
load the form, the id that I place are the categories that I do not want to
appear

def formfield_for_manytomany(self, db_field, request, **kwargs):
        if db_field.name == "category":
            kwargs["queryset"] =
Category.objects.exclude(id__in=[2,3,4,5,6]) #this id i like exclude
            print "see queryset"
            print kwargs["queryset"]
        return super(PostAdmin,
self).formfield_for_manytomany(db_field,request, **kwargs)

Any suggestions why it is not working
The code to exclude categories ??

thank

-- 
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/CAM-7rO1XbpDXwH63UsnpERAS4bGQ7%3DV-m6xLk1__0jDaa0A0mA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to