Python 属性错误:模块';django.contrib.auth.admin';没有属性';站点';
我遇到了错误: AttributeError:模块“django.contrib.auth.admin”没有属性“site” 尝试获取Django管理站点的URL时 这是我在Python 属性错误:模块';django.contrib.auth.admin';没有属性';站点';,python,django,attributeerror,Python,Django,Attributeerror,我遇到了错误: AttributeError:模块“django.contrib.auth.admin”没有属性“site” 尝试获取Django管理站点的URL时 这是我在url.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
url.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)
我哪里出错了?您在django.contrib
中查找的是admin
模块,而不是django.contrib.auth
,根据。django.contrib.auth
中的admin
模块用于自定义身份验证,而不是访问管理员站点详细信息
from django.contrib import admin
path('admin/', admin.site.urls)
如果我的回答解决了你的问题,你能帮我解决吗?这将有助于我们将这个问题标记为已解决。