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 commands to work because the following error:
NameError: name 'include' is not defined.
My project (Security) urls.py is the following, which does have include:
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')),
]
My Accounts apps.py contains:
from django.apps import AppConfig
class AccountsConfig(AppConfig):
name = 'accounts'
My Accounts app urls.py is the following:
from django.conf.urls import url, include
from . import views
urlpatterns = [
url(r'^$', views.home, name='home'),
]
My settings.py has accounts in the installed apps:
INSTALLED_APPS = [
'accounts',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
]
After adding include to be in both urls.py for my project and app, i'm now greeted with the following stating accounts module is not found.
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 978, in _gcd_import
File "<frozen importlib._bootstrap>", line 961, in _find_and_load
File "<frozen importlib._bootstrap>", line 948, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'accounts.url'
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With