Django не может найти страницу администратора
Я создаю приложение для блога на Django и хочу получить доступ к встроенной странице администратора. Однако, когда я пытаюсь зайти на нее, она продолжает выдавать ошибку 404, и я понятия не имею, почему.
Итак, когда я пытаюсь получить доступ к http://127.0.0.1:8000/admin/. я получаю:
Page not found (404)
Request Method: GET
Request URL: http://127.0.0.1:8000/admin/
Using the URLconf defined in blog.urls, Django tried these URL patterns, in this order:
[name='index']
posts [name='posts']
posts/<slug:slug> [name='post']
The current path, admin/, didn’t match any of these.
You’re seeing this error because you have DEBUG = True in your Django settings file. Change that to False, and Django will display a standard 404 page.
Примечание: проект называется 'my_site', а приложение - 'blog'
Ниже приведены некоторые фрагменты кода:
my_site/urls.py
from django.contrib import admin
from django.urls import path, include
urlpatterns = [
path('admin/', admin.site.urls),
path('', include('blog.urls'))
]
blog/urls.py
from django.urls import path
from . import views
urlpatterns = [
path('', views.index, name='index'),
path('posts', views.posts, name='posts'),
path('posts/<slug:slug>', views.post, name='post'),
]
blog/views.py
from django.shortcuts import render, get_object_or_404
from .models import Author, Post
# Create your views here.
def index(request):
all_posts = Post.objects.all().order_by("-date")
latest_posts = all_posts[:3]
return render(request, "blog/index.html", {
"posts": latest_posts
})
def posts(request):
return render(request, "blog/posts.html", {
"posts": Post.objects.all().order_by("date")
})
def post(request, slug):
post_detail = get_object_or_404(Post, slug=slug)
return render(request, "book_outlet/book_detail.html", {
"post": post_detail
})
Пожалуйста, подскажите, где искать виновника?