Re: Filtering ForeignKey Drop Down in Admin Interface

2012-04-12 Thread Setiaman Lee
Hi, Thanksit works like champion. Rgrds, Setiaman Lee On Wed, Apr 11, 2012 at 3:00 PM, Святослав Б wrote: > Hi! > > Override ModelAdmin get_form() method and filter your field. > > class MyAdmin(admin.ModelAdmin): >     def get_form(self, request, obj=None, **kwargs): >     form = super

Re: Filtering ForeignKey Drop Down in Admin Interface

2012-04-11 Thread Святослав Б
Hi! Override ModelAdmin get_form() method and filter your field. class MyAdmin(admin.ModelAdmin): def get_form(self, request, obj=None, **kwargs): form = super(MyAdmin,self).get_form(request, obj,**kwargs) form.base_fields['field'].queryset = form.base_fields['field'].queryset

Filtering ForeignKey Drop Down in Admin Interface

2012-04-10 Thread Setiaman Lee
Hi, I managed to set in the QuerySet of ModelAdmin to only allow user to see their own record. But when the child model link to parent model using ForeignKey a Drop Down will be automatically created for the respective column. Is there anyway to filter the drop down to only show the records that