Hello,
I’am having a Question about URL redirection:
In my project I have the following urls.py:
from django.contrib import admin
from django.urls import path, include
urlpatterns = [
path(‘admin/’, admin.site.urls),
path(‘’, include(‘leden.urls’)),
]
I also created a App named leden with the following config:
from django.urls import path
from .views import Home, RegisterView
urlpatterns = [
path(‘’, Home, name=‘leden-home’),
path(‘register/’, RegisterView.as_view(), name=‘leden-register’),
]
In my app I configured added the following code:
from django.shortcuts import render, redirect
from django.contrib import messages
from django.views import View
from .forms import RegisterForm
Create your views here.
def Home(request):
return render(request, ‘leden/home.html’)
And in my app I created a templates\leden folder where my home.html is located. when i run the server and going to 127.0.0.1:8000 I am getting the following error:
Page not found (404)
Request Method: | GET |
---|---|
Request URL: | http://127.0.0.1:8000/leden/ |
Using the URLconf defined in website.urls
, Django tried these URL patterns, in this order:
- admin/
- [name=‘leden-home’]
- register/ [name=‘leden-register’]
The current path, leden/
, didn’t match any of these.
Hopefully you can help figuring out what Iam doing wrong
Thank’s in advance
Roel Knippen