Commit 2ec98359 authored by impfundev's avatar impfundev

fix: refactor book form

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