Closed McQueTX closed 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)
My bad, the object is now in kwargs instead of arg.
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)