37 lines
981 B
Python
37 lines
981 B
Python
from django.shortcuts import render, HttpResponse
|
|
from . import models
|
|
# Create your views here.
|
|
|
|
def index(request):
|
|
artchle = models.articles.objects.all()
|
|
artchles = {"artchles": []}
|
|
print(artchle)
|
|
for i in artchle:
|
|
a = {
|
|
"id":i.id,
|
|
"title": i.title,
|
|
"abstract": i.abstract,
|
|
"created": i.created,
|
|
"stat": i.stat,
|
|
"read": i.read
|
|
}
|
|
artchles["artchles"].append(a)
|
|
return render(request, 'index.html', context=artchles)
|
|
# return HttpResponse("Hello, world. You're at the polls index.")
|
|
|
|
|
|
def archives(request, id):
|
|
i = models.articles.objects.get(id=id)
|
|
i.read += 1
|
|
i.save()
|
|
a = {
|
|
"id": i.id,
|
|
"title": i.title,
|
|
"abstract": i.abstract,
|
|
"created": i.created,
|
|
"stat": i.stat,
|
|
"read": i.read,
|
|
"content": i.content,
|
|
"author": i.author
|
|
}
|
|
return render(request, 'archives.html', a) |