Reputation: 2644
The Problem I want to solve is the following: E.g. we have https://example.com/?id=e46Hd3cDe. But I want to make it look nicer so I want users to be able to go to this link: https://example.com/e46Hd3cDe and get the same HTML file returned.
How could I achieve this in Django?
If I would have to change something in the Apache config, how could I do that while testing Django locally? Currently, I test my Django website by calling python manage.py runserver
and opening it at localhost:8000.
Upvotes: 0
Views: 1707
Reputation: 50
In Django, in your urls.py
, define in url_patterns
:
url_patterns = [
path('/<int:id>', view_name_goes_here),
]
Then, configure the corresponding functions in your views.py
to accept the id
parameter and get the corresponding object.
You don't need to modify your Apache config beyond adding in the WGSI
setup for Django.
Upvotes: 2