Added widgets to the input fields

parent a0c62a19
from django import forms
from django.forms import ModelForm from django.forms import ModelForm
from .models import Author, Books from .models import Author, Books
...@@ -7,8 +8,42 @@ class AuthorForm(ModelForm): ...@@ -7,8 +8,42 @@ class AuthorForm(ModelForm):
model = Author model = Author
fields = "__all__" fields = "__all__"
labels = {
'first_name': '',
'last_name': '',
'age': '',
'nationality': '',
'bio': '',
}
widgets = {
'first_name': forms.TextInput(attrs={'class': 'form-control', 'placeholder': 'First Name'}),
'last_name': forms.TextInput(attrs={'class': 'form-control', 'placeholder': 'Last Name'}),
'age': forms.NumberInput(attrs={'class': 'form-control', 'placeholder': 'Age'}),
'nationality': forms.TextInput(attrs={'class': 'form-control', 'placeholder': 'Nationality'}),
'bio': forms.Textarea(attrs={'class': 'form-control', 'placeholder': 'Biography'}),
}
class BooksForm(ModelForm): class BooksForm(ModelForm):
class Meta: class Meta:
model = Books model = Books
fields = "__all__" fields = "__all__"
labels = {
'title': '',
'author': '',
'publisher': '',
'year_published': '',
'ISBN': '',
'blurb': '',
}
widgets = {
'title': forms.TextInput(attrs={'class': 'form-control', 'placeholder': 'Book Title'}),
'author': forms.Select(attrs={'class': 'form-control', 'placeholder': 'Book Author'}),
'publisher': forms.TextInput(attrs={'class': 'form-control', 'placeholder': 'Publisher'}),
'year_published': forms.NumberInput(attrs={'class': 'form-control', 'placeholder': 'Year Published'}),
'ISBN': forms.NumberInput(attrs={'class': 'form-control', 'placeholder': 'ISBN Number'}),
'blurb': forms.Textarea(attrs={'class': 'form-control', 'placeholder': 'Blurb'}),
}
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