I googled this problem and didn't find anything that would help.
Here comes my project structure:
-myproject
-controlpanel
-urls.py
-views.py
-templates
-controlpanel
-index.html
-include
-navbar.html
-main
-urls.py
-views.py
-templates
-main
-index.html
-partials
-navbar.html
-myproject
-urls.py
And this is my controlpanel urls.py file:
from django.urls import path
from . import views
urlpatterns = [
path('', views.index, name='index'),
path('servers', views.servers, name='servers'),
]
This is my main urls.py file:
from django.urls import path
from . import views
urlpatterns = [
path('', views.index, name='index'),
path('join', views.join, name='join'),
path('rules', views.rules, name='rules'),
path('services', views.services, name='services'),
path('stats', views.stats, name='stats'),
path('gdpr', views.gdpr, name='gdpr'),
path('login', views.login, name='login'),
]
This is myproject urls.py:
from django.contrib import admin
from django.urls import include, path
urlpatterns = [
path('', include('main.urls')),
path('controlpanel/', include('controlpanel.urls')),
path('admin/', admin.site.urls),
]
Now when a user doesn't specify any subdirectory he should be redirected to index.html in app main.
The problem is that some {% url 'urlname' %} return urls from other projects. For instance when i used {% url 'index' %} in main apps navbar it used url controlpanel/index which it isn't supposed to do.
This also happened to me when I was creating a navbar for controlpanel and imported CSS but I solved it by renaming the folder to "include". I would generally just rename files to fix it to something like index > home, etc.. but this app is supposed to be copied to existing projects and I don't want to do it in this dirty way.
I don't know how to fix it. Any help would be appreciated.
question from:
https://stackoverflow.com/questions/66052562/django-urls-overlapping