Post app & Settings

This commit is contained in:
2020-05-03 18:53:54 +00:00
parent 52623ef98d
commit 88ad66de73
13 changed files with 200 additions and 11 deletions

View File

@@ -1,3 +1,20 @@
from django.shortcuts import render
from django.http import HttpResponse
from collections import deque
from .models import Post
from taggit.models import Tag
# Create your views here.
def index(request):
posts=deque(Post.objects.all())
return render(request, 'posts/index.html', {"posts": posts})
def show(request,id=None):
print("id: %s" % id)
print("is_digit:%s" % id.isdigit())
if id.isdigit() or id is int:
p=Post.objects.get(id=int(id))
elif id != ""and not id is None:
p=Post.objects.get(slug=(id))
return render(request, 'posts/show.html', {"post":p})