Guest User

Untitled

a guest
Jul 11th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. ## causes_extras.py (in causes/templatetags)
  2. from django import template
  3. from media_library.models import Collection, Video
  4. from locations.models import Location
  5. from causes.models import Cause
  6.  
  7. register = template.Library()
  8.  
  9. @register.inclusion_tag('media_library/_cause_locations.html')
  10. def get_causes(cause):
  11. cause_locations = Location.objects.filter(collection__causes=cause).filter(video__causes=cause)
  12. return {'cause_locations': cause_locations }
  13.  
  14. ## _cause_locations.html
  15. {% for location in cause_locations %}
  16. <a href="/">{{ location.name }}</a>{% if not forloop.last %}, {% endif %}
  17. {% endfor %}
Add Comment
Please, Sign In to add comment