[Django]-Include is not defined

7👍

You are using the include function in a file in which you’re not importing it. You should add

from django.conf.urls import url, include

to your security app urls.py

EDIT

For the second error, try and change the way you include the urls from accounts. Replace accounts.url for it’s relative path, starting with the apps folder. For example

url(r'^account/', include('accounts.urls')),

If you have doubts, add your folder structure to the question and I will update the answer properly.

2👍

Here’s the solution:

from django.conf.urls import include

import it on urls.py page of your project.

0👍

In your rootapp.py you have used
urlpatterns = [
url(r'^admin/', admin.site.urls),
url(r'^account/', include('accounts.url')),
]
Here you have used include('accounts.url')
But you have not imported include 
So your code should be

from django.apps import AppConfig


class AccountsConfig(AppConfig):
    name = 'accounts'

my security app urls.py is the following:

from django.conf.urls import url , include
from django.contrib import admin

urlpatterns = [
    url(r'^admin/', admin.site.urls),
    url(r'^account/', include('accounts.url')),
]

0👍

Hi i’m not sure but it works for me. I just installed the module include with this command (in the virtual environment):

pip install include

The script no longer displays error.

0👍

First try ‘pip install include’

or

you forgot to save your views.py and urls.py

or

add this in your urls.py ‘from django.conf.urls import include’

👤Harold

Leave a comment