0

I have a base file in my django template and it has an image in my nav that of the employee:

<img src="{% static 'assets/dist/img/employee/'1.jpg' %}" class="rounded-circle" width="50" height="50" alt="user"></a>

And i need that 1.jpg received {{user.employee.id}} but i can't concat .. i try this but not work:

<img src="{% static 'assets/dist/img/employee/'|add:{{user.employee.id}}|add:'.jpg' %}" class="rounded-circle" width="50"
                                     height="50" alt="user"></a>
Levi Cruz
  • 35
  • 6
  • Depends on version of Django see: https://stackoverflow.com/questions/16655851/django-1-5-how-to-use-variables-inside-static-tag – Ben Feb 14 '20 at 18:50
  • @Ben, tks, but i use s3 storage, i'll have problems?? – Levi Cruz Feb 14 '20 at 19:10
  • In that case you probably just want to pass the image url through the view context, for ex: in view `context["employee"] = employee` and in html `` – Ben Feb 14 '20 at 19:38
  • @Ben, this is my problem, this a base template, don't have view... – Levi Cruz Feb 14 '20 at 19:52

0 Answers0