problem of dynamic url rendering in template condition

54 views
Skip to first unread message

Saifullah Shahen

unread,
Jul 5, 2021, 8:55:38 AM7/5/21
to Django REST framework
I am facing a problem with a dynamic URL. So how can I use in dynamic URL in template conditions where there has many person's id.


asa.PNG
asa.PNG

sum abiut

unread,
Jul 5, 2021, 2:40:42 PM7/5/21
to django-res...@googlegroups.com
Try this:

{% if user.id == url ' message' user.id % }

 <h3>active</h3>
{% endif %}

--
You received this message because you are subscribed to the Google Groups "Django REST framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-rest-fram...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-rest-framework/de94bd89-f5f1-4743-b967-398d893d83e7n%40googlegroups.com.

Jelmer Draaijer

unread,
Jul 5, 2021, 3:01:59 PM7/5/21
to django-res...@googlegroups.com
The philosophy of the Django Template Language wants you "to bear in mind that the Django template system is not simply Python embedded into HTML". 

My solution should be to add user_id to the context data as current_user_id, your comparison is then simply {% if user.id == current_user_id %}. 

Op ma 5 jul. 2021 om 20:40 schreef sum abiut <sua...@gmail.com>:


--
06-1511 8153
KvK-nummer: 56685149
Btw-nummer: NL203949365B01
Bankrekening: NL12 BUNQ 2290 0564 56

Reply all
Reply to author
Forward
0 new messages