On Tue, Mar 3, 2009 at 3:31 PM, nivhab <yaniv.ha...@gmail.com> wrote:

>
> Here's the form class.
> Thanks, Yaniv
>
>
> -------------------------------------------------------------------------------------------
> from busa.models import User
> from django.utils.translation import ugettext_lazy as _
> from django import forms
>
> class UserForm(forms.ModelForm):
>    """
>    A form that creates a user, with no privileges, from the given
> username and password.
>    """
>
>    class Meta:
>        model = User
>
>    def clean_username(self):
>        username = self.cleaned_data["username"]
>        try:
>            u = User.all().filter('username=', username).fetch(1)
>            if (len(u) == 0):
>                return username
>            else:
>                raise forms.ValidationError(_("A user with that
> username already exists."))
>        except Exception:
>            return username
>
>    def clean_password2(self):
>        password1 = self.cleaned_data.get("password1", "")
>        password2 = self.cleaned_data["password2"]
>        if password1 != password2:
>            raise forms.ValidationError(_("The two password fields
> didn't match."))
>        return password2
>
>    def save(self, commit=True):
>        user = super(UserForm, self).save(commit=False)
>        user.set_password(self.cleaned_data["password1"])
>        if commit:
>            user.save()
>        return user
>
> class UserCreationForm(UserForm):
>    email = forms.EmailField(label=_("E-mail"), max_length=75)
>    password1 = forms.CharField(label=_("Password"),
> widget=forms.PasswordInput)
>    password2 = forms.CharField(label=_("Confirm Password"),
> widget=forms.PasswordInput)
>    tos = forms.BooleanField(widget=forms.CheckboxInput(),
>                             label=_(u'I have read and agree to the
> Terms of Service'),
>                             error_messages={ 'required': u"You must
> agree to the terms to register" })
>
>
> -------------------------------------------------------------------------------------------
>
>
>
> On Mar 3, 10:20 pm, Alex Gaynor <alex.gay...@gmail.com> wrote:
> > On Tue, Mar 3, 2009 at 3:18 PM, nivhab <yaniv.ha...@gmail.com> wrote:
> >
> > > Hi,
> >
> > > I am using django on google app engine, and also using the app-engine-
> > > patch package.
> > > I am getting this error when trying to save a form:
> >
> > > Exception Value:        'NoneType' object has no attribute 'properties'
> > > Exception Location:
> \Development\google_appengine\google\appengine\ext
> > > \db\djangoforms.py in save, line 795
> >
> > > The problem is in the creation of an iterator for model properties:
> >
> > >    self._meta.model.properties().iteritems()
> >
> > > That's because self._meta.model is 'None'. On the other hand
> > > self.Meta.model seems to be created properly (and the Meta class is
> > > contained in the form and does specify the model class).
> >
> > > Any idea what happened that makes the _meta.model not to exist?
> >
> > > Thanks!
> > > Yaniv
> >
> > You haven't pasted your form class itself, so we can't well say what's
> not
> > correct.  Please give us your form class so we have something to work
> with.
> >
> > Alex
> >
> > --
> > "I disapprove of what you say, but I will defend to the death your right
> to
> > say it." --Voltaire
> > "The people's good is the highest law."--Cicero
> >
> As far as I know you can't use django ModelForms with google app engine.

Alex


-- 
"I disapprove of what you say, but I will defend to the death your right to
say it." --Voltaire
"The people's good is the highest law."--Cicero

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to