Commit a2727c82 authored by Jan Ericsson Ong Ang's avatar Jan Ericsson Ong Ang

updated forms.py

parent a0c246cc
from django import forms from django import forms
from django.db import models from .models import Books, Author
from models import Author
class AuthorForm(forms.Form): class AuthorForm(forms.ModelForm):
first_name = forms.CharField(label='first_name', max_length=50) class Meta:
last_name = forms.CharField(label='last_name', max_length=50) model = Author
age = forms.IntegerField(label='age') fields = "__all__"
nationality = forms.CharField(label='nationality', max_length=50)
bio = forms.TextField(label='bio', max_length=700)
class BookForm(forms.Form): class BookForm(forms.ModelForm):
title = forms.CharField(label='title', max_length=50) class Meta:
author = forms.ForeignKey(Author, on_delete=models.CASCADE) model = Books
publisher = forms.CharField(label='publisher', max_length=50) fields = "__all__"
year_published = forms.IntegerField(label='year_published', max_length=50) \ No newline at end of file
ISBN = forms.CharField(label='ISBN', max_length=50)
blurb = forms.CharField(label='blurb', max_length=50)
\ No newline at end of file
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