On Mon, Feb 7, 2011 at 3:38 PM, SimpleDimple <farhandevelo...@gmail.com>wrote:
> I am new to django and building a school system but am experience > developer otherwise having firm grip over rails, php, .net and java. > > I have student table and in list I can see list of all students/ > records in student table....(pasted below is my code) > > what I want here is a custom dropdown listing the classes in school > from class table, and when you select/change the class the list of > students should get filtered accordingly....can someone please give me > hints or guide me a bit ? > > > > class StudentAdmin(admin.ModelAdmin): > fields = ['xclass', 'name', 'reg_no' , 'roll_no' ] > list_display = ['xclass', 'name', 'reg_no' , 'roll_no' ] > list_filter = ['name', 'reg_no' , 'roll_no' ] > search_fields = ['name', 'reg_no' , 'roll_no' ] > > form = StudentForm > > def queryset(self, request): > school_id = request.session['school_id'] > qs = self.model._default_manager.filter(school=school_id) > return qs > > def save_model(self, request, obj, form, change): > school_id = request.session['school_id'] > school = School.objects.get(id=school_id) > obj.school = school > obj.save() > > > -- > 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. > > This topic has come up recently under different specifics. When you change your filter (by selecting a specific class) you need to requery with that condition. This can be done by submitting the form to get a new dataset, or by using AJAX style to have the data retrieved on the fly to repopulate your form. -- Joel Goldstick -- 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.