David Hany
David Hany

Reputation: 13

django admin form won't be modify

from django import forms
from .models import SignUp

class forml(forms.ModelForm):

    class Meta:
        model = SignUp
        fields = ['Email', 'Name']
        # exclude =['sam']

    def clean_email(self):
        email = self.cleaned_data.get('Email') 
        email_base, ext = email.split("@")  
        exname, domain = ext.split(".")     
        if not domain == "gov":
            raise forms.ValidationError("plz write .gov")
        return email

here i'm trying to force the user to sign up with .gov email but for a reason that i can't know it's doing the work !

Upvotes: 0

Views: 40

Answers (1)

jarussi
jarussi

Reputation: 1579

Your problem is with the uppercase field names.

have you tried calling def clean_Email(self): ???

Also, consider having all your fields lowercase. In python, only class name should be Camelcase.

Hope it helps.

Upvotes: 3

Related Questions