'No module named '*.urls'
So I'm creating a new Django app, which I've done a couple of times. However, right now it looks like it's not possible to add the include from django.urls for some reason?
I keep getting the "No module named companies.urls" whilst it's 100% there...
Here is the setup:
urls.py - includes "companies.urls", redirecting to companies/urls.py
from django.contrib import admin
from django.urls import include, path
urlpatterns = [
path('admin/', admin.site.urls),
path('api/', include('companies.urls'), name='Companies'),
]
companies/urls.py - the urls.py where it refers to
from django.urls import path
from . import views
from .views import *
app_name = 'Companies'
urlpatterns = [
path('', views.getRoutes, name='Router'),
path('companies/', views.getCompanies, name='getCompanies'),
]
settings.py - showing that the app "companies" is added to installed apps
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'users',
'companies',
]
Please help me out, I'm really at a loss here. I basically started copying from an older Django project where it does work. But I'm running Django 4.0.4 and the documentation sides with my implementation.
Solution 1:[1]
Okay I found the solution. I'm used to working with IntelliJ but since it doesn't have good JS support (for free) I switched to VSCode. I forgot to specify the file extension of companies/urls. Its name was "urls" instead of "urls.py".
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | y3ll0ww |
