From 55bccb930fa64e646c6592cbe3efd1a7ad96490c Mon Sep 17 00:00:00 2001 From: Adam Goldsmith Date: Wed, 16 Feb 2022 16:32:51 -0500 Subject: [PATCH] Add a pdm script to run code formatters --- pyproject.toml | 1 + rentals/forms.py | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 rentals/forms.py diff --git a/pyproject.toml b/pyproject.toml index f81ac94..d22a0ae 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -47,6 +47,7 @@ lint = [ [tool.pdm.scripts] start = "./manage.py runserver" +fmt.shell = "black . && djlint --reformat ." [build-system] requires = ["pdm-pep517"] diff --git a/rentals/forms.py b/rentals/forms.py new file mode 100644 index 0000000..0b15179 --- /dev/null +++ b/rentals/forms.py @@ -0,0 +1,20 @@ +from django import forms + +from rentals.models import LockerInfo + + +class BoostrapModelForm(forms.ModelForm): + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + for field in self.fields.values(): + field.widget.attrs["class"] = "form-control" + + +class LockerInfoForm(BoostrapModelForm): + class Meta: + model = LockerInfo + fields = [ + "blind_code", + "bitting_code", + "renter", + ]