Is it safe to set a modeladmin variable and use it like this; it is set in the changelist_view based on the url search criteria and is used to limit the choices of a foreign key when adding new item
class MyModelAdmin(reversion.VersionAdmin): ... selected_period = None def formfield_for_foreignkey(self, db_field, request, **kwargs): if db_field.name == "period": kwargs["queryset"] = Period.objects.filter(id=self.selected_period) return super(MyModelAdmin, self).formfield_for_foreignkey(db_field, request, **kwargs) def changelist_view(self, request, extra_context=None): .. if request.GET.has_key('period__id__exact'): self.selected_period = request.GET['period__id__exact'] return super(MyModelAdmin, self).changelist_view(request, extra_context=extra_context) admin.site.register(MyClassroomAbsenceLog, MyClassroomAbsenceLogAdmin) -- 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/02120fbc-8f78-4d65-b0b8-d503434b8f6f%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.