Django if statement & loop


/ Published in: Django
Save to your folder(s)



Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.