0

I have 3 apps inside django project (leadmanager) leads, frontend, accounts

Everything is working fine if I dont include accounts.urls (from accounts app) in leadmanager.urls but as soon as I include accounts.urls I getting the following error (all of these apps are registered in settings.py):

$ python manage.py runserver
Watching for file changes with StatReloader
Performing system checks...

Exception in thread django-main-thread:
Traceback (most recent call last):
File "C:\Users\Danial Ahmed\Desktop\Learning\django-react\venv\lib\site-packages\django\urls\resolvers.py", line 591, in url_patterns
    iter(patterns)
TypeError: 'module' object is not iterable

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "C:\Users\Danial Ahmed\AppData\Local\Programs\Python\Python36\lib\threading.py", line 916, in _bootstrap_inner        
    self.run()
File "C:\Users\Danial Ahmed\AppData\Local\Programs\Python\Python36\lib\threading.py", line 864, in run
    self._target(*self._args, **self._kwargs)
File "C:\Users\Danial Ahmed\Desktop\Learning\django-react\venv\lib\site-packages\django\utils\autoreload.py", line 53, in wrapper
    fn(*args, **kwargs)
File "C:\Users\Danial Ahmed\Desktop\Learning\django-react\venv\lib\site-packages\django\core\management\commands\runserver.py", line 118, in inner_run
    self.check(display_num_errors=True)
File "C:\Users\Danial Ahmed\Desktop\Learning\django-react\venv\lib\site-packages\django\core\management\base.py", line 396, in check
    databases=databases,
File "C:\Users\Danial Ahmed\Desktop\Learning\django-react\venv\lib\site-packages\django\core\checks\registry.py", line 70, 
in run_checks
    new_errors = check(app_configs=app_configs, databases=databases)
File "C:\Users\Danial Ahmed\Desktop\Learning\django-react\venv\lib\site-packages\django\core\checks\urls.py", line 13, in check_url_config
    return check_resolver(resolver)
File "C:\Users\Danial Ahmed\Desktop\Learning\django-react\venv\lib\site-packages\django\core\checks\urls.py", line 23, in check_resolver
    return check_method()
File "C:\Users\Danial Ahmed\Desktop\Learning\django-react\venv\lib\site-packages\django\urls\resolvers.py", line 408, in check
    for pattern in self.url_patterns:
File "C:\Users\Danial Ahmed\Desktop\Learning\django-react\venv\lib\site-packages\django\utils\functional.py", line 48, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
File "C:\Users\Danial Ahmed\Desktop\Learning\django-react\venv\lib\site-packages\django\urls\resolvers.py", line 598, in url_patterns
    raise ImproperlyConfigured(msg.format(name=self.urlconf_name)) from e
django.core.exceptions.ImproperlyConfigured: The included URLconf 'leadmanager.urls' 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.

leadmanager.url (main):

urlpatterns = [
    path('admin/', admin.site.urls),
    path('',include('frontend.urls')),
    path('',include('leads.urls')),
    path('',include('accounts.urls')),
]

lead.urls:

from rest_framework import routers
from .api import LeadViewSet

router = routers.DefaultRouter()
router.register('api/leads', LeadViewSet, 'leads')
app_name = 'leads'
urlpatterns = router.urls

accounts.urls:

from django.urls import path, include
from .api import ReigsterAPI
from knox import views as knox_views

app_name = 'accounts'
urlpatterns = [
  path('api/auth', include('knox.urls')),
  path('api/auth/register', RegisterAPI.as_view()),
]

frontend.urls:

from django.urls import path
from . import views

urlpatterns = [
    path('',views.index),
]
5
  • If this happens when you add accounts.url to your base URLs, have you tried removing the two paths from accounts.urls? Or replacing both with a simple TemplateView? Commented Jan 9, 2021 at 16:26
  • @FlipperPA yes if just put path('auth/', TemplateView.as_view(template_name='index.html')) in url patterns it works fine. Commented Jan 9, 2021 at 17:29
  • 1
    So let's figure out whether it is path('api/auth', include('knox.urls')), or path('api/auth/register', RegisterAPI.as_view()), causing the problem - trying commenting out each one individually and see which kicks the error? If it is knox.urls, then we'll have to dig into that app's urls.py to find the culprit. :) Commented Jan 10, 2021 at 2:54
  • @FlipperPA tried that, but are giving same error Commented Jan 10, 2021 at 8:07
  • 1
    @FlipperPA Got it fixed! Commented Jan 10, 2021 at 8:42

1 Answer 1

1

In .api I was import serializers.py but I had a typing mistake, my file was called serailizers.py, after fixing name of file everything started working!

I just wish that there was someway to detect this syntax errors, because the error I received was not very helpful.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.