I have looked at other answers to this question, but I still can't figure out what's wrong.
Generally, there are two urls.py - one in my account
folder, and another one in my bookmarks
folder which are in the root folder - bookmarks
.
When I try to create a superuser, I get this:
django.core.exceptions.ImproperlyConfigured: The included URLconf '<module 'account.urls' from '/Users/aleksanderjess/Documents/PacktPub/Django/bookmarks/account/urls.py'>' does not appear to have any patterns in it. If you see valid patterns in the file then the issue is probably caused by a circular import.
I have absolutely no clue why. The imports look legit and all.
Here are two urls.py
account/urls.py
:
from django.contrib.auth import views
from . import views
urls = [
path('login/', views.user_login, name='login'),
]
and then there's the one in bookmarks, which looks like this:
from django.contrib import admin
from django.urls import path, include
from django.conf import settings
from django.conf.urls.static import static
urlpatterns = [
path('admin/', admin.site.urls),
path('account/', include('account.urls')),
]
One defines the list of url patterns in a variable named urlpatterns
, not , as is specified in the documentation on URL dispatching [Django-doc]:urls
(...)
Django loads that Python module and looks for the variable
urlpatterns
. This should be a Python list ofdjango.urls.path()
and/ordjango.urls.re_path()
instances.(...)
So the system thus raises an error that you appear to have forgotton something. You can fix it by renaming urls
to urlpatterns
:
# account/urls.py
from django.contrib.auth import views
from . import views
urlpatterns = [
path('login/', views.user_login, name='login'),
]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With