8👍
You are correct in that the error stems from repeating path('admin/', admin.site.urls),
in all of your url.py files. It is normally only declared at the root level as others have pointed out.
Think of it like this – You wouldn’t want to have a separate admin interface for each app, rather you would want to be able to manage all of your apps from one admin interface which is exactly what occurs when you have it only in the root urls.py file.
Also, although the apps should be modular and independent they still need to be connected to a project to work.
21👍
You are declaring
path('admin/', admin.site.urls),
three times in your urls files. You just have to declare it once in the root urls.py of your project.
- 'instancemethod' object has no attribute '__getitem__'
- Is it possible to create subparsers in a django management command?
2👍
Set your main/urls.py as
from django.urls import path
from django.views.generic import TemplateView
urlpatterns = [
path(
"header/",
TemplateView.as_view(template_name="header.html")),
]
And fix this inside the main URLs file teachers/urls.py as follows:
from django.contrib import admin
from django.urls import path, include
from django.conf import settings
urlpatterns = [
path(
'admin/',
admin.site.urls),
path('',
include('main.urls')),
]
- Save image created via PIL to django model
- How can I programmatically add content to a Wagtail StreamField?
- Python/Django "BadStatusLine" error
- In Django, how can I get an exception's message?
- Log all errors to console or file on Django site
0👍
it’s because of multiple declarations of that admin path. remove those extra line path(‘admin/’, admin.site.urls) line from urls.py file except the project’s url.py
- Put the result of simple tag into a variable
- Django command: How to insert newline in the help text?
- Getting raise KeyError(key) KeyError: 'SECRET_KEY' with django on production settings
- Override existing django-admin command
- Django: duplicates when filtering on many to many field
- Serving root-level static files on Heroku with Django?
- How do I set HttpOnly cookie in Django?
- Django import export – Unable to import model with BinaryField
- Soft deleting objects in django
- Django save model with anonymous user