Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AttributeError: module 'django.contrib.auth.admin' has no attribute 'site'

I encountered the error:

AttributeError: module 'django.contrib.auth.admin' has no attribute 'site'.

when attempting to get the URL of the Django admin site.

Here is my code in urls.py:

from django.contrib.auth import admin
from django.urls import path, include
from django.conf import settings
from django.conf.urls.static import static
urlpatterns = [

path('', include('adoption.urls')),
path('accounts/', include('accounts.urls')),
path('admin/', admin.site.urls)
]
urlpatterns= urlpatterns+ static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

Where did I go wrong?

like image 812
Pavana Rhk Avatar asked Jun 22 '26 17:06

Pavana Rhk


1 Answers

You are looking for the admin module within django.contrib, rather than django.contrib.auth, as per the documentation. The admin module in django.contrib.auth is for customizing authentication, rather than accessing the admin site details.

from django.contrib import admin
path('admin/', admin.site.urls)
like image 89
dspencer Avatar answered Jun 25 '26 07:06

dspencer



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!