Django 2.0 change in request.path ?

15 views
Skip to first unread message

Michael Schietzsch

unread,
Dec 11, 2017, 7:11:20 AM12/11/17
to Django users
Hi,

I just recently started with Django (and python for that matter). I started to create a page using Django 1.11 and now migrated it to 2.0 
I have for one small problem, and that is that a request.path in my tempalte is not working anymore, and I can not figure out why. I could not find any part in the changes or documentation that it should work any different now.
Here is the short code snippet:


{% url 'profile' as profile_url %} {% if request.path == profile_url %}
<button type="button" class="btn btn-outline-success btn-sm active" onClick="javascript:history.go(-1);">{% user_display user %}</button>
{% else %}
<a class="btn btn-outline-success btn-sm" href="/profile" role="button">{% user_display user %}</a>
{% endif %}


What it did was changing a button (primarily the active state or css of it). So if you are currently on the profile page, the buttin will be lit and a klick will bring you back (sort of), if not the buttin will be normal and bring you to your profile.
Why? Because that button is in the NAV bar.

I hope someone can help me out here.
Thank
Regards
Michael
Reply all
Reply to author
Forward
0 new messages