Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## causes_extras.py (in causes/templatetags)
- from django import template
- from media_library.models import Collection, Video
- from locations.models import Location
- from causes.models import Cause
- register = template.Library()
- @register.inclusion_tag('media_library/_cause_locations.html')
- def get_causes(cause):
- cause_locations = Location.objects.filter(collection__causes=cause).filter(video__causes=cause)
- return {'cause_locations': cause_locations }
- ## _cause_locations.html
- {% for location in cause_locations %}
- <a href="/">{{ location.name }}</a>{% if not forloop.last %}, {% endif %}
- {% endfor %}
Add Comment
Please, Sign In to add comment