Commit 2ec98359 authored by impfundev's avatar impfundev

fix: refactor book form

parent 90f0d56e
from django import forms from django import forms
from books.models import Book
class BookForm(forms.Form): class BookForm(forms.ModelForm):
title = forms.CharField( class Meta:
max_length=100, model = Book
widget=forms.TextInput( fields = ["title", "stock", "description"]
attrs={
"placeholder": "Title", widgets = {
"class": "form-control", "title": forms.TextInput(
} attrs={
), "placeholder": "Title",
) "class": "form-control",
stock = forms.IntegerField( }
widget=forms.TextInput( ),
attrs={ "stock": forms.TextInput(
"type": "number", attrs={
"placeholder": "Stock", "type": "number",
"class": "form-control", "placeholder": "Stock",
} "class": "form-control",
), }
) ),
description = forms.CharField( "description": forms.Textarea(
max_length=255, attrs={
widget=forms.Textarea( "placeholder": "Description",
attrs={ "class": "form-control",
"placeholder": "Description", }
"class": "form-control", ),
} }
),
)
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