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"]
widgets = {
"title": forms.TextInput(
attrs={ attrs={
"placeholder": "Title", "placeholder": "Title",
"class": "form-control", "class": "form-control",
} }
), ),
) "stock": forms.TextInput(
stock = forms.IntegerField(
widget=forms.TextInput(
attrs={ attrs={
"type": "number", "type": "number",
"placeholder": "Stock", "placeholder": "Stock",
"class": "form-control", "class": "form-control",
} }
), ),
) "description": forms.Textarea(
description = forms.CharField(
max_length=255,
widget=forms.Textarea(
attrs={ attrs={
"placeholder": "Description", "placeholder": "Description",
"class": "form-control", "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