Display template, book list, and admin page changes.

This commit is contained in:
Mike Young
2019-11-17 10:22:17 -05:00
parent 5f41716b63
commit 5255eff365
3 changed files with 31 additions and 10 deletions

View File

@@ -1,3 +1,6 @@
from django.contrib import admin
from .models import Books
# Register your models here.
admin.site.register(Books)

View File

@@ -3,7 +3,7 @@ from django.db import models
# Create your models here.
class books(models.Model):
class Books(models.Model):
"""
pyShelfs Book Database class
:param title: Book title
@@ -14,10 +14,20 @@ class books(models.Model):
:param progress: Reader percentage <-- Not implented
:param file_name: Path to book
"""
class Meta:
db_table = 'books'
def __str__(self):
return self.title
title = models.CharField(max_length=255)
author = models.CharField(max_length=255, blank=True)
categories = models.CharField(max_length=255, blank=True)
cover = models.BinaryField(blank=True, editable=True)
pages = models.IntegerField(blank=True)
progress = models.IntegerField(blank=True)
file_name = models.CharField(max_length=255, blank=False)
author = models.CharField(max_length=255, null=True)
categories = models.CharField(max_length=255, null=True)
cover = models.BinaryField(null=True, editable=True)
pages = models.IntegerField(null=True)
progress = models.IntegerField(null=True)
file_name = models.CharField(max_length=255, null=False)
def get_absolute_url(self):
"""Returns the url to access a particular instance of MyModelName."""
return reverse('model-detail-view', args=[str(self.id)])

View File

@@ -1,7 +1,15 @@
from django.http import HttpResponse
from django.shortcuts import render
# Create your views here.
from .models import Books
def index(request):
return HttpResponse("HTTP Request")
return render(request, "index.html", {'Books': Books.objects.all()})
def book_set(_set):
r = 20
x = _set*r
y = x + r
books = Books.objects.all()[x:y]
return books