[英]TypeError: 'module' object is not callable (+static(settings.MEDIA_URL,document_root=settings.MEDIA_ROOT))
[英]Django Admin Page not found (404), urls.py + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
轉到http://127.0.0.1:8000/admin
返回此錯誤:
Using the URLconf defined in the_food_blog.urls, Django tried these URL patterns, in this order:
admin/
[name='home']
<slug:slug>/ [name='post_detail']
^(?P<path>.*)$
The current path, admin, matched the last one.
網址.py
urlpatterns = [
path('admin/', admin.site.urls),
path('', include('blog.urls')),
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
網址.py
urlpatterns = [
path('', views.PostList.as_view(), name='home'),
path('<slug:slug>/', views.PostDetail.as_view(), name='post_detail'),
]
刪除+ static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
解決了這個問題,但為什么呢?
你可以使用這些:
網址.py
urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
設置.py
MEDIA_URL = '/media/'
我希望能解決你的問題!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.