First version
This commit is contained in:
23
CTOAsYouGo/core/forms.py
Normal file
23
CTOAsYouGo/core/forms.py
Normal file
@@ -0,0 +1,23 @@
|
||||
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.")
|
||||
Reference in New Issue
Block a user