Commit e4afc3ca authored by Stefan Gomez's avatar Stefan Gomez

Filled the models and the admin files of the project accordingly.

parent 3bed98bf
from django.contrib import admin
from.models import Author, Books
class AuthortAdmin(admin.ModelAdmin):
model = Author
class BooksAdmin(admin.ModelAdmin):
model = Books
admin.site.register(Author, AuthorAdmin)
admin.site.register(Books, BooksAdmin)
from django.apps import AppConfig
class BookshelfConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'bookshelf'
from django.db import models
class Author(models.Model):
first_name = models.CharField(max_length=100)
last_name = models.CharField(max_length=100)
age = models.IntegerField()
nationality = models.CharField(max_length=20)
bio = models.TextField(max_length=700)
def __str__(self):
return '{}, {}'.format(self.last_name, self.first_name)
class Books(models.Model):
title = models.CharField(max_length=100)
author = models.ForeignKey(
Author,
on_delete=models.CASCADE
)
publisher = models.CharField(max_length=100)
year_published = models.IntegerField()
ISBN = models.IntegerField()
blurb = models.TextField(max_length =200)
def __str__(self):
return '{}'.format(self.title)
\ No newline at end of file
from django.test import TestCase
# Create your tests here.
from django.shortcuts import render
# Create your views here.
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