I'm trying to use formfield_for_foreignkey to filter the dropdown of a 
ModelAdmin with Django 1.6 on Python 2.7.6, following 
https://docs.djangoproject.com/en/1.6/ref/contrib/admin/

class CupAdmin(admin.ModelAdmin):
    ...

    # hide inactive distributions
    def formfield_for_foreignkey(self, db_field, request=None, **kwargs):
        if db_field.name == 'distribution':
            kwargs["queryset"] == Distribution.objects.exclude(active=False)
        return super(CupAdmin, self).formfield_for_foreignkey(db_field, 
request, **kwargs)

My code fails because kwargs has no queryset, for both adding or editing

Django Version:1.6Exception Type:KeyErrorException Value:

'queryset'


When looking at localvars in the traceback, kwargs is empty ( {} )

Am I (or the docs) missing something?

-- 
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/810a2fde-e903-43a0-975e-0f9c04dd0506%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to