I am getting this error “If you see valid patterns in the file then the issue is probably caused by a circular import in”. I saw other stack flow questions and I know the error is coming from views.py but I cannot seem to figure out where the error is
views.py/myapp
JavaScript
x
7
1
from django.shortcuts import render
2
from django.http import HttpResponse
3
4
# Create your views here.
5
def index(request):
6
return HttpResponse('<h1>Hey,Welcome</h1>')
7
urls.py/myapp
JavaScript
1
7
1
from django.urls import path
2
from myapp import views
3
4
urlpattern = [
5
path('',views.index, name='index')
6
]
7
urls.py/myproject
JavaScript
1
16
16
1
from django.contrib import admin
2
from django.urls import path, include
3
4
urlpatterns = [
5
path('admin/', admin.site.urls),
6
path('',include('myapp.urls'))
7
]
8
9
Performing system checks
10
11
Exception in thread django-main-thread:
12
Traceback (most recent call last):
13
File "C:Usersanaconda3libsite-packagesdjangourlsresolvers.py", line 698, in url_patterns
14
iter(patterns)
15
TypeError: 'module' object is not iterable
16
The above exception was the direct cause of the following exception:
JavaScript
1
29
29
1
Traceback (most recent call last):
2
File "C:Usersanaconda3libthreading.py", line 973, in _bootstrap_inner
3
self.run()
4
File "C:Usersanaconda3libthreading.py", line 910, in run
5
self._target(*self._args, **self._kwargs)
6
File "C:Usersanaconda3libsite-packagesdjangoutilsautoreload.py", line 64, in wrapper
7
fn(*args, **kwargs)
8
File "C:Usersanaconda3libsite-packagesdjangocoremanagementcommandsrunserver.py", line 134, in inner_run
9
self.check(display_num_errors=True)
10
File "C:Usersanaconda3libsite-packagesdjangocoremanagementbase.py", line 487, in check
11
all_issues = checks.run_checks(
12
File "C:Usersanaconda3libsite-packagesdjangocorechecksregistry.py", line 88, in run_checks
13
new_errors = check(app_configs=app_configs, databases=databases)
14
File "C:Usersanaconda3libsite-packagesdjangocorechecksurls.py", line 14, in check_url_config
15
return check_resolver(resolver)
16
File "C:Usersanaconda3libsite-packagesdjangocorechecksurls.py", line 24, in check_resolver
17
return check_method()
18
File "C:Usersanaconda3libsite-packagesdjangourlsresolvers.py", line 481, in check
19
messages.extend(check_resolver(pattern))
20
File "C:Usersanaconda3libsite-packagesdjangocorechecksurls.py", line 24, in check_resolver
21
return check_method()
22
File "C:Usersanaconda3libsite-packagesdjangourlsresolvers.py", line 480, in check
23
for pattern in self.url_patterns:
24
File "C:Usersanaconda3libsite-packagesdjangoutilsfunctional.py", line 49, in __get__
25
res = instance.__dict__[self.name] = self.func(instance)
26
File "C:Usersanaconda3libsite-packagesdjangourlsresolvers.py", line 706, in url_patterns
27
raise ImproperlyConfigured(msg.format(name=self.urlconf_name)) from e
28
django.core.exceptions.ImproperlyConfigured: The included URLconf '<module 'myapp.urls' from 'E:\projects\django\myproject\myapp\urls.py'>' does not appear to have any patterns in it. If you see the 'urlpatterns' variable with valid patterns in the file then the issue is probably caused by a circular import.
29
Advertisement
Answer
Could you please just change urlpattern
to urlpatterns
in urls.py/myapp
and see if that solves your problem.