Django: ModuleNotFoundError ...... No module named 'admin'

created at Feb. 27, 2021, 12:26 p.m.

if you got this error in your django project, you could:

#1 Check your settings.py

in your settings.py, you should have apps:

INSTALLED_APPS=[ 
    "django.contrib.admin",  # note to add this admin app
    "django.contrib.auth",
    "django.contrib.contenttypes",
    "django.contrib.sessions",
    "django.contrib.sites",
    "django.contrib.messages",
    ]  

#2 Check your urls.py

for django 3.x, you probably need to set the admin url as:

from django.contirb import admin

urlpatterns = [
    ...
    path('admin/', admin.site.urls),
    ...
]

rather than:

urlpatterns = [
    ...
    path('admin/', include('admin.site.urls')),
    ...
]
Please log in to leave a comment.