Works  with

{% if request.path == '/profile/' %}

I kind of forgot that I used a URL module with 1.11...


Am Montag, 11. Dezember 2017 13:11:20 UTC+1 schrieb Michael Schietzsch:
>
> Hi,
>
> I am pretty new to Django (and therefore python). I started to write a 
> website with Django 1.11 and now tried to migrate it to 2.0
> I got most working with the help of the new documentation, but I have a 
> problem with request.path usage in a template. It worked fine with 1.11 but 
> not with 2.0. I was not able to find that anything changed with 
> request.path in 2.0
> Here is the template 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 does is, change a button, depending on the current URL. In 
> practice:
> The button is locate in a ever present nav bar. 
> If you are on your profile (/profile) than the button will be in active 
> state, and a click will go one back (sort of)
> If not, the buttin not active and will on klick send you to your profile
>
> Currently is will never be in the if true situation.
>
> I hope you can help me
> Thanks
> Regards
> Michael
>
> p.s.: I thought I already posted this, but could not find it, so here as a 
> repost. If it shows up twice, I am very sorry and will punish my browser 
> thoroughly ;-)
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/1a41f20b-7eef-4255-b829-eee3076842fb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
  • DJango 2.0 request.path 'Michael Schietzsch' via Django users
    • Re: DJango 2.0 request.path 'Michael Schietzsch' via Django users

Reply via email to