Redirecting from urls.py

I made some changes and slashed a page.

Now it is possible some users have the page bookmarked or on an email and I wanted this to work but to not retain the url.

At the same time I did’t want to create a view just for that.

There is a better way:

from django.views.generic import RedirectView

...

urlpatterns = [
...
path(
"measurementpoint/<uuid:pk>/history/",
RedirectView.as_view(pattern_name="measurementpoint", permanent=True),
),
...
]


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

About Me

My name is Tasos Sangiotis and I work at Arpedon, an engineering company. This website is a collection of posts, essays and photos. They are mainly about travel, food and technical stuff. Occasionally I shoot photos. They are mostly on Instagram. If you choose to wander this wasteland do so with caution. Consider this your final warning. To contact me use [email protected]

Newsletter