Dan Neal
Dan Neal

Reputation: 1

having problems with a circular import error

I have been trying to learn how to code using python and Django and have been having a lot of fun with it but recently I have hit a little snag. I have been working on trying to fix the problem for the last few days but can't figure things out. When I try to start up the Django development server, I get the following error:

raise ImproperlyConfigured(msg.format(name-self.urlconf_name)) Django.core.exceptions.ImproperlyConfigured: The included URLconf '' 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.

Any help would be greatly appreciated. I am trying to set the music app up so that when queried will send an index file.

website.urls

from django.contrib import admin
from django.urls import include, path

urlpatterns = [
path('admin/', admin.site.urls),
path('music/', include('music.urls'))

music.urls

from django.urls import path
from . import views

path('', views.index, name="index")

music.views

from django.http import HttpResponse

def index(request):
return HttpResponse("<h1> This is my Home Page </h1>")

Upvotes: 0

Views: 804

Answers (1)

solarissmoke
solarissmoke

Reputation: 31404

Change this:

path('', views.index, name="index")

to:

urlpatterns = [
    path('', views.index, name="index")
]

You need to put your paths inside a urlpatterns variable for Django to find them.

Upvotes: 2

Related Questions