Guest User

Untitled

a guest
Nov 21st, 2018
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.67 KB | None | 0 0
  1. <div class="container">
  2. {% for post in post_list_highlighted %}
  3.  
  4. <h1><a href="{{ post.get_absolute_url }}">{{ post.title }}</a></h1>
  5. <p>Pubblicato il <em>{{ post.publishing_date }}</em></p>
  6. <small>
  7. {% for tags in post.tag.all %}
  8. <a href="{{ tags.get_absolute_url }}">{{ tags }}</a>
  9. {% endfor %}
  10. </small><br>
  11. <a href="{{ post.category.get_absolute_url }}">{{ post.category }}</a>
  12. <hr>
  13.  
  14. {% empty %}
  15.  
  16. <div class="jumbotron my-5">
  17. <h1 class="text-center">Non hai creato ancora nulla!</h1>
  18. </div>
  19.  
  20. {% endfor %}
  21. </div>
  22.  
  23. {% extends 'base.html' %}
  24.  
  25. {% load static %}
  26.  
  27. {% block head_title %}Elenco Post | {{ block.super }}{% endblock head_title %}
  28.  
  29. {% include 'blog/list_posth.html' %}
  30.  
  31. {% block content %}
  32.  
  33.  
  34. <div class="row">
  35. <div class="col-sm-10">
  36. {% for post in post_list %}
  37. <h1><a href="{{ post.get_absolute_url }}">{{ post.title }}</a></h1>
  38. <!-- <img class="img-fluid mx-auto d-block" src="{{ post.image }}" alt="Image of {{ post.title }}"> -->
  39. <p>Pubblicato il <em>{{ post.publishing_date }}</em></p>
  40. <small>
  41. {% for tags in post.tag.all %}
  42. <a href="{{ tags.get_absolute_url }}">{{ tags }}</a>
  43. {% endfor %}
  44. </small><br>
  45. <a href="{{ post.category.get_absolute_url }}">{{ post.category }}</a>
  46. <hr>
  47. {% empty %}
  48. <div class="jumbotron my-5">
  49. <h1 class="text-center">Non hai creato ancora nulla!</h1>
  50. </div>
  51.  
  52. {% endfor %}
  53. </div>
  54.  
  55. <div class="col-sm-2">
  56. <h1>Archivio</h1>
  57.  
  58. {% regroup all_posts by publishing_date.year as year_list %}
  59.  
  60. <ul>
  61. {% for year in year_list %}
  62. <li>{{ year.grouper }}
  63. {% regroup year.list by publishing_date.month as month_list %}
  64. <ul>
  65. {% for month in month_list %}
  66. <li><a href="{% url 'post_list_archive_month' year.grouper month.grouper %}">{{ month.list.0.publishing_date|date:'b' }} ({{ month.list|length }})</a></li>
  67. {% endfor %}
  68. </ul>
  69. </li>
  70. {% endfor %}
  71. </ul>
  72.  
  73. </div>
  74.  
  75. </div>
  76.  
  77. {% endblock content %}
  78.  
  79. class PostListHighlighted(ListView):
  80. model = Post
  81. queryset = Post.objects.filter(highlighted=True)
  82. context_object_name = 'post_list_highlighted'
  83. template_name = "blog/list_posth.html"
  84.  
  85.  
  86. class PostList(ListView):
  87. model = Post
  88. queryset = Post.objects.filter(highlighted=False)
  89. context_object_name = 'post_list'
  90. template_name = "blog/list_post.html"
  91. paginate_by = 4
  92.  
  93. path("", PostList.as_view(), name="list_post"),
  94. path("highlighted/", PostListHighlighted.as_view(), name="list_post_highlighted"),
Add Comment
Please, Sign In to add comment