1 from django.forms import ModelForm
2 from models import Sandwich, Ingredient
3 from django.contrib.auth.models import User
4 from django import forms
7 class SandwichForm(ModelForm):
11 exclude = ('slug', 'user', 'ingredients')
12 fields = ('adjective', 'date_made', 'notes', 'picture')
15 class IngredientForm(ModelForm):
22 class NewUserForm(forms.Form):
23 first_name = forms.CharField()
24 last_name = forms.CharField()
25 email = forms.EmailField()
26 username = forms.CharField()
27 password = forms.CharField(widget=forms.PasswordInput)
28 confirmpassword = forms.CharField(label=("Confirm password"), widget=forms.PasswordInput)
30 def clean_confirmpassword(self):
31 password = self.cleaned_data.get("password", "")
32 cpassword = self.cleaned_data["confirmpassword"]
33 if password != cpassword:
34 raise forms.ValidationError(("The two password fields didn't match."))