Trying to trace a circular import error in Django

后端 未结 10 2067
被撕碎了的回忆
被撕碎了的回忆 2021-02-05 09:00

I understand circular import error has been asked about a lot but after going through these questions I haven\'t been able to solve my issue. When I try to run my server in Djan

相关标签:
10条回答
  • 2021-02-05 09:14

    In my case i was getting this error because i was typing urlpatterns in urls.py to urlpattern.

    0 讨论(0)
  • 2021-02-05 09:20

    this error basically occurs when you have, include the app in the main urls.py file and haven't declared urlpattern= [] in-app file.

    0 讨论(0)
  • 2021-02-05 09:22

    Try changing

    urlpatterns = [
         url(r'^accounts/', include('accounts_app')),
    ] 
    

    to

    urlpatterns = [
         url(r'^accounts/', include('accounts_app.urls')), # add .urls after app name
    ]
    
    0 讨论(0)
  • 2021-02-05 09:24

    In my case, I got this error because I called the reverse function for a url that required a slug parameter without placing the correct parameter in it.

    Once I fixed the reverse function, it was resolved.

    0 讨论(0)
  • 2021-02-05 09:28

    for those who have the same error but still hasn't debugged their code, also check how you typed "urlpatterns"

    having it mistyped or with dash/underscore will result to the same error

    0 讨论(0)
  • 2021-02-05 09:34

    In my case, I was getting

    /SLMS_APP1/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 made a typo in 'urlpatter'

    urlpatter = [ path('',views.index, name='index'),

    ]

    where in correct spelling has to be 'urlpatterns'

    urlpatterns = [ path('',views.profile, name='profile'),

    ]

    0 讨论(0)
提交回复
热议问题