daily pastebin goal
4%
SHARE
TWEET

Untitled

a guest Jul 11th, 2018 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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 %}
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top