Monday, February 29, 2016

How force DJANGo choice MEDIA_URL or STATIC_URL in template?


I need choice base url MEDIA_URL (/media/) - for uploaded user picture, or STATIC_URL (/static/) - picture by default

I am try next:

p><img src="{% if account.accountuserinfo.picture %}MEDIA{% else %}STATIC{% endif %}_URL{{ account.accountuserinfo.picture_url }}" alt="picture_for_{{ account.name }}" id="account_picture"></p>

, but result is MEDIA_URL(STATIC_URL) and path to file.

I am next try:

{% templatetag openvariable %} url 'entry_list' {% templatetag closevariable %}

but result is {{ MEDIA_URL }} or {{ STATIC_URL }} (not working)

may by anyone known how solved this problem
---------------------------------------------------

Thanks

--
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+unsubscribe@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/72159edf-e841-41ce-8513-571b142d4f24%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment