24 lines
869 B
Python
24 lines
869 B
Python
from django import forms
|
|
from django.core.exceptions import ValidationError
|
|
from .models import Request
|
|
|
|
class RequestForm(forms.ModelForm):
|
|
class Meta:
|
|
model = Request
|
|
fields = ['task', 'email', 'email_confirmation', 'description', 'price_from', 'price_to', 'needed_information', 'title']
|
|
widgets = {
|
|
'task': forms.HiddenInput(),
|
|
'price_from': forms.HiddenInput(),
|
|
'price_to': forms.HiddenInput(),
|
|
'needed_information': forms.HiddenInput(),
|
|
'title': forms.HiddenInput(),
|
|
}
|
|
|
|
def clean(self):
|
|
cleaned_data = super().clean()
|
|
email = cleaned_data.get("email")
|
|
email_confirmation = cleaned_data.get("email_confirmation")
|
|
|
|
if email != email_confirmation:
|
|
raise ValidationError("Email confirmation does not match with the email.")
|