Yuravangenrih

Untitled

Aug 12th, 2015
333
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.54 KB | None | 0 0
  1. from django.shortcuts import render, get_object_or_404
  2. from django.shortcuts import render_to_response
  3. from blog.models import Article
  4.  
  5.  
  6. def home(request):
  7.     articles = Article.objects.all()
  8.     context = {
  9.         'articles': articles
  10.     }
  11.     return render(request, 'blog/home.html', context)
  12.  
  13.  
  14. def about(request):
  15.     return render(request,'blog/about.html')
  16.  
  17. def show_article(request,article_id):
  18.     article = get_object_or_404(Article, id=article_id)
  19.     return render(request, 'blog/article.html', {'article':article})
Advertisement
Add Comment
Please, Sign In to add comment