-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathviews.py
46 lines (29 loc) · 841 Bytes
/
views.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
from django.shortcuts import render
from django.shortcuts import get_object_or_404
from .models import Article
from .models import Category
# Create your views here.
def front_page(request):
return render(request, 'blog/front_page.html', {
})
def articles(request):
articles = Article.objects.all()
return render(request, 'blog/articles.html', {
'articles':articles
})
def article(request, article):
article = get_object_or_404(Article, slug=article)
category = article.category
return render(request, 'blog/article.html', {
'article':article,
'category':category,
})
def categories(request):
return {
'categories':Category.objects.all()
}
def category(request, slug):
category = get_object_or_404(Category, slug=slug)
return render(request, 'blog/category.html', {
'category':category
})