Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Got The included URLconf does not appear to have any patterns in it

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')),
]

like image 877
Aleksander Jess Avatar asked Feb 23 '19 16:02

Aleksander Jess


1 Answers

One defines the list of url patterns in a variable named urlpatterns, not urls, as is specified in the documentation on URL dispatching [Django-doc]:

(...)

Django loads that Python module and looks for the variable urlpatterns. This should be a Python list of django.urls.path() and/or django.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'),
]
like image 189
Willem Van Onsem Avatar answered Sep 21 '22 16:09

Willem Van Onsem