1👍
✅
You are importing the wrong module, you are importing it from django
, so not your own. You can use:
from django.contrib import admin
from django.urls import path
from app_name.views import my_form
urlpatterns = [
path('admin/', admin.site.urls),
path('form', my_form, name='form'),
]
Where app_name
is the name of the app where you have a views.py
where you defined that view.
Note: URLs normally have a trailing slash (i.e.
form/
instead ofform
). In fact, by default theAPPEND_SLASH
setting [Django-doc], which is by default set toTrue
, will first try to match the path, and if no match is found, and the requested path has no slash, it will retry with an appended slash.
Source:stackexchange.com