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.
41 lines
962 B
41 lines
962 B
from django.forms import ModelForm, HiddenInput
|
|
from .models import Project, Portfolio, Answer
|
|
|
|
class ProjectForm(ModelForm):
|
|
class Meta:
|
|
model = Project
|
|
|
|
fields = (
|
|
'name',
|
|
'price',
|
|
'specialization',
|
|
'text',
|
|
)
|
|
|
|
|
|
class PortfolioForm(ModelForm):
|
|
class Meta:
|
|
model = Portfolio
|
|
fields = '__all__'
|
|
|
|
|
|
class AnswerForm(ModelForm):
|
|
def __init__(self, *args, **kwargs):
|
|
self.project_id = kwargs.pop('project_id')
|
|
super().__init__(*args, **kwargs)
|
|
# import code; code.interact(local=dict(globals(), **locals()))
|
|
self.fields["project"].initial = self.project_id
|
|
|
|
class Meta:
|
|
model = Answer
|
|
fields = (
|
|
'cost',
|
|
'cost_type',
|
|
'text',
|
|
'term',
|
|
'term_type',
|
|
'project',
|
|
)
|
|
widgets = {
|
|
'project': HiddenInput(),
|
|
}
|
|
|