I’m new to django. The question I have is simple, but I couldn’t really figure out what I needed from tutorials I have found online, nor in a book I have purchased on django.
I am writing a website to house an online comic. Let’s say the url is:
http://localhost:8000/
I want a request for the base url to go to the most recent comic. If there are 13 comics, then I want a user requesting the above url to be sent to:
http://localhost:8000/13
At the same time, I want a user that types in http://localhost:8000/13 to go to the url specified. How would I do this?
For that you will need two url patterns which will map to two views. The first url is for the home page (
http://localhost:8000/), and the second url is to see a specific comic (http://localhost:8000/<comic_id>). The first url however should redirect users to the latest comic usingHttpResponseRedirect.