Search code examples
pythondjangodjango-viewsrequest-response

Circular Import in Django


I have been trying to run a client-server application using Django. When I am trying to run my server in Django , it is giving me the following error.

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.

The project urls.py -

from django.conf.urls import url,include
from django.contrib import admin
urlpatterns = [
url(r'^admin/', admin.site.urls),
url(r'^', include('chat.views')),
] 

App's views.py -

from django.shortcuts import render
from django.http import JsonResponse
def home(request):
if request.method == 'POST':

    if request.is_ajax():

       //code
        return JsonResponse(data)

return render(request,'index.html')

Where am I going wrong?


Solution

  • include method takes app urls.py model not views.py. You need to create urls.py file inside your app and replace url(r'^', include('chat.views')) with url(r'^', include('chat.urls')) in projects urls file. See django docs.