Hi,
I’m struggling with what I suspect to be a pip related issue.
My Django version is 3.2.3, running under Ubuntu 21.10.
I’d like to use django-nested-admin
in my project. With venv activated, I type:
$ python3 -m pip install django-nested-admin
The installation runs fine. Then I declare the app in settings.py:
INSTALLED_APPS = [
...
'nested_admin',
]
I also included the URL in urls.py
(as stated here, even if I don’t use django-grappelli. In my specific issue, I tried with and without including the URL and the result is the same):
urlpatterns = [
...
path('_nested_admin/', include('nested_admin.urls')),
]
Now, trying to import nested_admin in admin.py
and to call the NestedTabularInline
class:
from django.contrib.gis import admin
import nested_admin
from notices.models import Illustration
class IllustrationAdmin(admin.ModelAdmin):
search_fields = ('legende', 'image')
class IllusInline(admin.NestedTabularInline):
model = Illustration
fields = ('image', 'legende', 'principale')
I get the following error when trying to run the dev server:
$ python3 manage.py runserver
Watching for file changes with StatReloader
Exception in thread django-main-thread:
Traceback (most recent call last):
File "/usr/lib/python3.9/threading.py", line 973, in _bootstrap_inner
self.run()
File "/usr/lib/python3.9/threading.py", line 910, in run
self._target(*self._args, **self._kwargs)
File "/home/jeremy/.local/lib/python3.9/site-packages/django/utils/autoreload.py", line 64, in wrapper
fn(*args, **kwargs)
File "/home/jeremy/.local/lib/python3.9/site-packages/django/core/management/commands/runserver.py", line 110, in inner_run
autoreload.raise_last_exception()
File "/home/jeremy/.local/lib/python3.9/site-packages/django/utils/autoreload.py", line 87, in raise_last_exception
raise _exception[1]
File "/home/jeremy/.local/lib/python3.9/site-packages/django/core/management/__init__.py", line 375, in execute
autoreload.check_errors(django.setup)()
File "/home/jeremy/.local/lib/python3.9/site-packages/django/utils/autoreload.py", line 64, in wrapper
fn(*args, **kwargs)
File "/home/jeremy/.local/lib/python3.9/site-packages/django/__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "/home/jeremy/.local/lib/python3.9/site-packages/django/apps/registry.py", line 122, in populate
app_config.ready()
File "/home/jeremy/.local/lib/python3.9/site-packages/django/contrib/admin/apps.py", line 27, in ready
self.module.autodiscover()
File "/home/jeremy/.local/lib/python3.9/site-packages/django/contrib/admin/__init__.py", line 24, in autodiscover
autodiscover_modules('admin', register_to=site)
File "/home/jeremy/.local/lib/python3.9/site-packages/django/utils/module_loading.py", line 47, in autodiscover_modules
import_module('%s.%s' % (app_config.name, module_to_search))
File "/usr/lib/python3.9/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 850, in exec_module
File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
File "/home/jeremy/partage/code/orag_bootstrap/notices/admin.py", line 10, in <module>
class IllusInline(admin.NestedTabularInline):
AttributeError: module 'django.contrib.gis.admin' has no attribute 'NestedTabularInline'
It’s like the django-nested-admin weren’t installed. I tried to $ python3 -m pip list
, within or without the virtual env. The command returns the same list of installed module. Is it normal?
Any help very appreciated, thanks!