Hi everyone,

I have two dropdowns on the create/ edit pages of an object in the admin
site. I need to filter the second dropdown's contents based on the
selection in the first (as a user-friendliness measure). I have tried the
recommended use of formfield_or_foreignkey with no progress. The difference
is that the following example uses the request object's user, whereas I
need a way to obtain and use the first dropdown's selected item.

I also noticed that the form does not post when a selection is made.

class MyModelAdmin(admin.ModelAdmin):
    def formfield_for_foreignkey(self, db_field, request, **kwargs):
        if db_field.name == "car":
            kwargs["queryset"] = Car.objects.filter(owner=request.user)
            return db_field.formfield(**kwargs)
        return super(MyModelAdmin,
self).formfield_for_foreignkey(db_field, request, **kwargs)


Any ideas?

-- 
Regards,
Sithembewena Lloyd Dube

-- 
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 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to