spacepaste

  1.  
  2. #VIEW
  3. def stats(request):
  4. obj = statistics.objects.filter(ig_username='user_number_one', action='FOLLOW').order_by('-id')[:1]
  5. template = loader.get_template('statistics.html')
  6. context = {
  7. 'obj':obj
  8. }
  9. #obj has 5 columns: id, ig_username, action, count_actions, date
  10. return HttpResponse(template.render(context, request))
  11. #TEMPLATE
  12. {% if obj %}
  13. <ul>
  14. {% for statistics in obj %}
  15. <div class = "user_table">
  16. <li>{{ statistics.ig_username }}<br>
  17. {{ statistics.action }}<br>
  18. {{ statistics.count_actions }}<br>
  19. {{ statistics.date }}<br>
  20. </li>
  21. {% endfor %}
  22. </ul>
  23. {% else %}
  24. <p>No stats are available.</p>
  25. {% endif %}
  26. </div>
  27. how could I subtract datetime.datetime.now with statistics.date ?
  28.