0👍
✅
After looking around and reading some documentation, here’s my approach
{% for a in activities %}
{% with a.extra_context as o %}
{% endwith %}
{% endfor %}
1👍
If you want to create a new list variable to iterate over, you need access to the template’s context – which I don’t think you can do from the template itself. As far as I know that must be done from the view. This question may provide more insight. The discussion of template tags found in the same thread is also relevant.
If activities
is the only thing being passed through the request context, then I believe the closest thing you can do from within the template without registering a new tag is:
{% for o in activities %}
{{ o.extra_context }}
<!-- do stuff -- >
{% endfor %}
I would refer to the above-linked thread for discussion on making a tag that can work with a new list, etc.
- [Answer]-Limit inlines to edit mode in Django's ModelAdmin
- [Answer]-Nodejs wont allow non local connections
- [Answer]-Cannot find screen.css compass/sass in django project that is compiling correctly
- [Answer]-Which is better practice, checking object exists in Manager or Method?
- [Answer]-UserProfile id == None in form validation / save
Source:stackexchange.com