KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I'm having some trouble overriding the queryset for my inline admin. Here's a bog-standard parent admin and inline admin: class MyInlineAdmin(admin.TabularInline): model = MyInlineModel def queryset(self, request): qs = super(MyInlineAdmin, self).queryset(request) return qs class ParentAdmin(admin.ModelAdmin): inlines = [MyInlineAdmin] admin.site.register(ParentAdminModel, ParentAdmin) Now I can do qs.filter(user=request.user) or qs.filter(date__gte=datetime.today()) no problem. But what I need is either the MyInlineModel instance or the ParentAdminModel instance (not the model!), as I need to filter my queryset based on that. Is it possible to get something like self.instance or obj (like in get_readonly_fields() or get_formset()) inside the queryset() method? Hope this makes sense. Any help is much appreciated.
Tags (comma-separated)
Save Edits
Cancel