django-nested-inline
django-nested-inline copied to clipboard
Django==4.1 request to admin/app_name/model/add/? ... raises models.FieldDoesNotExist when using NestedStackedInline and NestedModelAdmin.
trafficstars
hi, there. request to admin/app_name/model/add/? ... raises models.FieldDoesNotExist when using NestedStackedInline and NestedModelAdmin.
here's the simplest example.
installed apps:
asgiref==3.5.2
Django==4.1.2
django-nested-admin==3.4.0
django-nested-inline==0.4.5
pipi==1.0.1
python-monkey-business==1.0.0
six==1.16.0
sqlparse==0.4.3
tzdata==2022.4
models.py
from django.db import models
class Parent(models.Model):
name = models.CharField(max_length=50)
class Child(models.Model):
name = models.CharField(max_length=50)
parent = models.ForeignKey(Parent, on_delete=models.CASCADE)
admin.py
from django.contrib import admin
from nested_inline.admin import NestedStackedInline, NestedModelAdmin
from .models import Child, Parent
admin.site.register(Child)
class ModelNestedInline(NestedStackedInline):
model = Child
extra = 1
@admin.register(Parent)
class ParentAdmin(NestedModelAdmin):
inlines = (ModelNestedInline,)
list_display = ('name',)
search_fields = ('name',)
request path: http://127.0.0.1:8080/admin/myapp/parent/add/?_changelist_filters=q%3Dhoge
exception:
Internal Server Error: /admin/myapp/parent/add/
Traceback (most recent call last):
File "D:\projects\django_test\venv\lib\site-packages\django\db\models\options.py", line 668, in get_field
return self.fields_map[field_name]
KeyError: '_changelist_filters'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "D:\projects\django_test\venv\lib\site-packages\nested_inline\admin.py", line 217, in add_view
f = opts.get_field(k)
File "D:\projects\django_test\venv\lib\site-packages\django\db\models\options.py", line 670, in get_field
raise FieldDoesNotExist(
django.core.exceptions.FieldDoesNotExist: Parent has no field named '_changelist_filters'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "D:\projects\django_test\venv\lib\site-packages\django\core\handlers\exception.py", line 55, in inner
response = get_response(request)
File "D:\projects\django_test\venv\lib\site-packages\django\core\handlers\base.py", line 197, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "D:\projects\django_test\venv\lib\site-packages\django\contrib\admin\options.py", line 686, in wrapper
return self.admin_site.admin_view(view)(*args, **kwargs)
File "D:\projects\django_test\venv\lib\site-packages\django\utils\decorators.py", line 133, in _wrapped_view
response = view_func(request, *args, **kwargs)
File "D:\projects\django_test\venv\lib\site-packages\django\views\decorators\cache.py", line 62, in _wrapped_view_func
response = view_func(request, *args, **kwargs)
File "D:\projects\django_test\venv\lib\site-packages\django\contrib\admin\sites.py", line 242, in inner
return view(request, *args, **kwargs)
File "D:\projects\django_test\venv\lib\site-packages\django\utils\decorators.py", line 46, in _wrapper
return bound_method(*args, **kwargs)
File "D:\projects\django_test\venv\lib\site-packages\django\utils\decorators.py", line 133, in _wrapped_view
response = view_func(request, *args, **kwargs)
File "C:\Program Files\Python310\lib\contextlib.py", line 79, in inner
return func(*args, **kwds)
File "D:\projects\django_test\venv\lib\site-packages\nested_inline\admin.py", line 218, in add_view
except models.FieldDoesNotExist: