daily pastebin goal
53%
SHARE
TWEET

Untitled

a guest Jan 17th, 2018 71 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. {% extends 'blog/base.html' %}
  2.  
  3. {% block content %}
  4. <div class="date">
  5.     {{ poste.author }}   #отображается
  6. </div>
  7.  
  8. {% for post in test %}
  9.     {{ post.title }}     #не отображается
  10. {% endfor %}
  11. {% endblock %}
  12.    
  13. def post_detail(request, pk):
  14.     poste = get_object_or_404(Post, pk=pk)
  15.     return render(request, 'blog/post_detail.html', {'poste': poste})
  16.  
  17. def post_test(request):
  18.     test = Post.objects.filter(published_date__lte=timezone.now())
  19.     return render(request, 'blog/similar_articles.html', {'test': test})
  20.    
  21. urlpatterns = [
  22. path('', views.post_list, name='post_list'),
  23. path('post/<int:pk>/', views.post_detail, name='post_detail'),
  24. ]
  25.    
  26. class Post(models.Model):
  27.    author = models.CharField(max_length=200)
  28.    title = models.CharField(max_length=200)
  29. ...
  30. def publish(self):
  31.    self.published_date = timezone.now()
  32.    self.save()
  33.  
  34. def __str__(self):
  35.     return self.title
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top