Reputation: 99
I'm new in Python & Django.
I am creating a new app using Python 3.6 Django 2.2.7 and for some reason, the url.py
which holds the urlpatterns of the project, is not recognizing the urls.py
of my new app (ManageMissingBusinesses
).
Please see below the relevant urls.py (on the project level).
urls.py (project level)
from django.urls import path, include
from app import forms
from datetime import datetime
import app.forms
import app.views
urlpatterns = [
path
('ManageMissingBusinesses/',include('ManageMissingBusinesses.urls'))
]
The urls.py on the project level is located on level above the ManageMissingBusinesses
module/directory.
While starting the server, I'm receiving an error on the urlpattern line:
path ('ManageMissingBusinesses/',include('ManageMissingBusinesses.urls'))
ModuleNotFoundError:No module named 'ManageMissingBusinesses'
Can you explain me what is the issue?
Upvotes: 2
Views: 1329
Reputation: 99
I managed to resolve the issue.
My problem was that my app directory was created using MS Visual Studio which has created a project under two directories having the same name (not sure what is the reason).
So the directories tree looks like:
Proj1 (visual studio files like sln file)
--Proj1 (where manage.py exists)
----Proj1 (where setting.py exists)
------myapp (the module name)
So I added the Proj1.myapp to the setting.py and the url.py files which solved the issue.
Upvotes: 2
Reputation: 2613
Go to YourProjectDir\settings.py and include your created app ManageMissingBusinesses
into the installed apps like so:
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'ManageMissingBusinesses'
]
For further reference take a look into https://docs.djangoproject.com/en/2.2/intro/tutorial02/
Upvotes: 1