Commit 69d6013b authored by Cheska Hung's avatar Cheska Hung

Cleaning code

parent 201aa1b4
Pipeline #3055 failed with stages
...@@ -2,6 +2,7 @@ from django.db import models ...@@ -2,6 +2,7 @@ from django.db import models
from django.core.validators import MaxValueValidator, MinValueValidator from django.core.validators import MaxValueValidator, MinValueValidator
from django.urls import reverse from django.urls import reverse
class Author(models.Model): class Author(models.Model):
first_name = models.CharField(max_length=50) first_name = models.CharField(max_length=50)
last_name = models.CharField(max_length=50) last_name = models.CharField(max_length=50)
...@@ -15,7 +16,8 @@ class Author(models.Model): ...@@ -15,7 +16,8 @@ class Author(models.Model):
class Books(models.Model): class Books(models.Model):
title = models.CharField(max_length=200) title = models.CharField(max_length=200)
author = models.ForeignKey(Author, related_name="books", on_delete=models.CASCADE) author = models.ForeignKey(Author, related_name="books",
on_delete=models.CASCADE)
publisher = models.CharField(max_length=200) publisher = models.CharField(max_length=200)
year_published = models.DateField() year_published = models.DateField()
ISBN = models.PositiveIntegerField( ISBN = models.PositiveIntegerField(
......
from django.shortcuts import render from django.shortcuts import render
from django.http import HttpResponse
from django.views.generic.detail import DetailView from django.views.generic.detail import DetailView
from django.views.generic.list import ListView from django.views.generic.list import ListView
from django.views import View
from .models import Books from .models import Books
from .models import Author from .models import Author
from django.views import generic
def HomeView(request): def HomeView(request):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment