H
H
Hcuy2020-08-28 16:12:47
Django
Hcuy, 2020-08-28 16:12:47

Django module not defined?

Hello! In the urls of the project, I add the inclusion string for the app urls module .

urlpatterns = [
    url('admin/', admin.site.urls),
    url('',app.urls, name = 'app')
]

But an error appears
url('',app.urls, name = 'app')
NameError: name 'app' is not defined

Applications and the project were created normally, the database works, the admin panel too.
Thank you!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
strange-capp, 2020-08-28
@Hcuy

I assume you set the application urls in the main urls.py
In this case, it should be done like this

from django.urls import include

# ...

urlpatterns = [
    # ...
    path('', include('app.urls', namespace='app')),
]

# ...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question