Skip to content Skip to sidebar Skip to footer

Include Is Not Defined

To clarify Security is the project folder, and Accounts is the app. I'm sure this is an elementary issue that i'm overlooking, but i've been struggling to get my manged.py command

Solution 1:

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

from django.conf.urlsimport 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.

Solution 2:

Here's the solution:

from django.conf.urlsimport include

import it on urls.py page of your project.

Solution 3:

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


classAccountsConfig(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')),
]

Solution 4:

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.

Solution 5:

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'

Post a Comment for "Include Is Not Defined"