I just started up with django.
Following this tutorial, I ended up with the following urls.py
:
from django.contrib import admin
from django.urls import include, path
urlpatterns = [
path('polls/', include('polls.urls')),
path('admin/', admin.site.urls),
]
This links to polls.urls.py
which has its own router.
The part I don't like is the string literal 'polls.urls' which is, well... a string literal.
I would like to somehow reference the file directly using some of python's power, and have AT LEAST my IDE protect me.
What happens if I want to move that polls.urls.py
file, or rename it, or rename polls? Should I trust my IDE to catch a reference from a string literal?
This is almost like doing this monstrosity, and is very hard for me to accept as the best practice.
It just seems odd to me.
Is there a way to use something less prone to errors than string literals in django's routers?