spacepaste

  1.  
  2. # Views.py
  3. @csrf_exempt
  4. def stats(request):
  5. obj = statistics.objects.filter(username='user_n1', action='FOLLOW').order_by('-id')[:1]
  6. template = loader.get_template('statistics.html')
  7. context = {
  8. 'obj':obj
  9. }
  10. return HttpResponse(template.render(context, request))
  11. # statistics.html file
  12. {% if obj %}
  13. <ul>
  14. {% for statistics in obj %}
  15. <div class = "user_table">
  16. <li>{{ statistics.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. # My question how could I subtract datenow from date from sql?
  28. # I do not know how can I access the date column from all these
  29.