On Jan 31, 6:40 am, sushanth Reddy <sushant...@gmail.com> wrote: > I am trying to create a dynamic filtered drop down choice fields,i gone > through below blog but it confusing,can any one suggest easy way to do this > in django.
Do you mean in the admin or on your live site? If in the admin, check out the docs on ModelAdmin.formfield_for_foreignkey: http://docs.djangoproject.com/en/1.1/ref/contrib/admin/ 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) If you're trying to do this on your live site, you can do whatever filtering you like in your view of course. -- 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.