You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

78 lines
1.9 KiB

from django import forms
from django.forms import ModelForm, HiddenInput, Form, Select
from django.forms.models import inlineformset_factory
from .models import Project, Portfolio, Answer, Realty, PortfolioPhoto, Stage
# RealtyFormSet = inlineformset_factory(Project, Realty)
class ProjectForm(ModelForm):
class Meta:
model = Project
fields = (
'name',
'price',
'specialization',
'text',
'type_work',
'secure_transaction',
)
class ProjectsForm(Form):
name = forms.CharField(max_length=255)
class RealtyForm(ModelForm):
class Meta:
model = Realty
fields = (
'name',
'building_classification',
'type_construction',
'country',
'city',
)
class PortfolioForm(ModelForm):
class Meta:
model = Portfolio
fields = '__all__'
class AnswerForm(ModelForm):
# def __init__(self, *args, **kwargs):
# # import code; code.interact(local=dict(globals(), **locals()))
# self.project_id = kwargs.pop('project_id')
# super().__init__(*args, **kwargs)
# self.fields["project"].initial = self.project_id
class Meta:
model = Answer
fields = (
'cost',
'cost_type',
'text',
'term',
'term_type',
)
widgets = {
# 'project': HiddenInput(),
'cost_type': Select(attrs={'class':'selectpicker'}),
'term_type': Select(attrs={'class':'selectpicker'}),
}
class StageForm(ModelForm):
class Meta:
model = Stage
fields = (
'name',
'result',
'cost',
'cost_type',
'term',
'term_type',
)
from django.forms.models import inlineformset_factory
PortfolioPhotoFormSet = inlineformset_factory(Portfolio, PortfolioPhoto, fields=('img',))