[Fixed]-How to design Django url pattern to avoid 301

1👍

✅

Your url pattern ends with a slash, so your url should as well.

To make sure you always point your urls to the canonical url and avoid redirects, use the {% url %} template tag:

<a href="{% url 'posts:slug' results.code %}?From=homepage" class="portfolio-link" target="_blank">

Here 'slug' is the name of your url, and results.code is an argument to the url.

0👍

You can use request.GET.get(‘From’, ”) in your views, and clean your url pattern.

Leave a comment