Project_Camper/vagus/camper/forms.py
2021-01-08 22:23:52 +01:00

19 lines
808 B
Python

from django import forms
from django.forms import formset_factory
from .models import Offer,Offer_Category,Image_offer
class OfferCreateForm(forms.ModelForm):
title = forms.CharField(label = 'Offer title', max_length=50)
price = forms.DecimalField(min_value=0.01,max_digits=10, decimal_places=2)
class Meta:
model = Offer
fields = ('title','category','price','DMC','Places_to_sleep','cooker','fridge', 'microwave', 'Webasto', 'auto_temp_control', 'water_level_indicator', 'battery_level', 'photovoltaic_panels', 'gearbox', 'tempomat')
class OfferImageCreateForm(forms.ModelForm):
image = forms.ImageField()
class Meta:
model = Image_offer
fields = ('image','main_image')
OfferImageFormSet = formset_factory(OfferImageCreateForm, extra = 5, max_num = 5)