Posted By

stewartduffy on 06/09/11


Tagged

loop if statement django


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

nerdfiles


Django if statement & loop


 / Published in: Django
 

  1. {% get_latest_jobs %}
  2. {% if latest_jobs.count %}
  3. <div class="job-listings">
  4. <h3>job listings</h3>
  5. <ul>
  6. {% for job in latest_jobs %}
  7. <li>
  8. <a href="{{ job.get_absolute_url }}"><strong>{{ job.title }}</strong><br>{{ job.location }}</a>
  9. </li>
  10. {% endfor %}
  11. </ul>
  12. </div>
  13. {% else %}
  14. <p>Sorry, but there are no jobs today..</p>
  15. {% endif %}

Report this snippet  

You need to login to post a comment.