Post app & Settings
This commit is contained in:
@@ -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})
|
||||
|
||||
Reference in New Issue
Block a user