I am a begginer with django and I am stuck in getting this to work, practically what I want is that the user types in the address bar http://website.com/example and then in Django I want to make a dynamic view where it checks the address and then redirects user to the correct page otherwise gives an error.
this is what I was trying but it might not be working..
urlpatterns = [
path("", views.index, name="index"),
path("<str:name>", views.example, name="example") ]
and then in the views.py
I want the following:
def example(request, name):
return render(request, "website/<name> here i want for it to insert what the user typed in the address bar", {
"name": util.get_entry(name) <-- this is a function which checks if there is that name in the database otherwise will return an error.
})
Hope I was clear with the question and thank you for the help :)
Aucun commentaire:
Enregistrer un commentaire