Import of django-nested-admin doesn't seem to work


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


I also included the URL in (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 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 runserver
Watching for file changes with StatReloader
Exception in thread django-main-thread:
Traceback (most recent call last):
  File "/usr/lib/python3.9/", line 973, in _bootstrap_inner
  File "/usr/lib/python3.9/", line 910, in run
    self._target(*self._args, **self._kwargs)
  File "/home/jeremy/.local/lib/python3.9/site-packages/django/utils/", line 64, in wrapper
    fn(*args, **kwargs)
  File "/home/jeremy/.local/lib/python3.9/site-packages/django/core/management/commands/", line 110, in inner_run
  File "/home/jeremy/.local/lib/python3.9/site-packages/django/utils/", line 87, in raise_last_exception
    raise _exception[1]
  File "/home/jeremy/.local/lib/python3.9/site-packages/django/core/management/", line 375, in execute
  File "/home/jeremy/.local/lib/python3.9/site-packages/django/utils/", line 64, in wrapper
    fn(*args, **kwargs)
  File "/home/jeremy/.local/lib/python3.9/site-packages/django/", line 24, in setup
  File "/home/jeremy/.local/lib/python3.9/site-packages/django/apps/", line 122, in populate
  File "/home/jeremy/.local/lib/python3.9/site-packages/django/contrib/admin/", line 27, in ready
  File "/home/jeremy/.local/lib/python3.9/site-packages/django/contrib/admin/", line 24, in autodiscover
    autodiscover_modules('admin', register_to=site)
  File "/home/jeremy/.local/lib/python3.9/site-packages/django/utils/", line 47, in autodiscover_modules
    import_module('%s.%s' % (, module_to_search))
  File "/usr/lib/python3.9/importlib/", 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/", 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!

You should use NestedTabularInline from nested_admin:

class IllusInline(nested_admin.NestedTabularInline):
1 Like

Of course! :man_facepalming: Thanks @felixxm!