theatlantic / django-nested-admin

Django admin classes that allow for nested inlines
http://django-nested-admin.readthedocs.org/
Other
715 stars 99 forks source link

Unable to get pk from request after upgrade from Django 1.11 to Django 3.1.1 #216

Closed McQueTX closed 2 years ago

McQueTX commented 2 years ago

I used to be able to limit the fk choices in a NestedTabularInline using the below code, but after the upgrade trying to set the tt variable locks up the server:

def formfield_for_foreignkey(self, db_field, request, kwargs): if db_field.name == "somefk": try: tt = request.resolver_match.args[0] kwargs["queryset"] = SomoeModel.objects.filter(some_id=tt) except IndexError: pass return super().formfield_for_foreignkey(db_field, request, kwargs)

McQueTX commented 2 years ago

My bad, the object is now in kwargs instead of arg.