update
This commit is contained in:
@@ -1,7 +1,27 @@
|
||||
from django import forms
|
||||
from .models import ExcelEntry
|
||||
from .models import ExcelEntry, Betriebskosten
|
||||
|
||||
class ExcelEntryForm(forms.ModelForm):
|
||||
class Meta:
|
||||
model = ExcelEntry
|
||||
fields = ['name', 'age', 'email'] # Include only the fields you want users to input
|
||||
fields = '__all__' # Include only the fields you want users to input
|
||||
|
||||
class BetriebskostenForm(forms.ModelForm):
|
||||
class Meta:
|
||||
model = Betriebskosten
|
||||
fields = ['buchungsdatum', 'rechnungsnummer', 'kostentyp', 'gas_volume', 'betrag', 'beschreibung']
|
||||
widgets = {
|
||||
'buchungsdatum': forms.DateInput(attrs={'type': 'date'}),
|
||||
'beschreibung': forms.Textarea(attrs={'rows': 3}),
|
||||
}
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
self.fields['gas_volume'].required = False
|
||||
|
||||
# Add price per liter field (readonly)
|
||||
self.fields['price_per_liter'] = forms.CharField(
|
||||
label='Preis pro Liter (€)',
|
||||
required=False,
|
||||
widget=forms.TextInput(attrs={'readonly': 'readonly'})
|
||||
)
|
||||
Reference in New Issue
Block a user