2009/5/17 zayatzz <alan.kesselm...@gmail.com>

>
> Thanks
>
> I actually tried that form.cleaned_data at one point but then i got
> error that was something like: form object has no cleaned_data
> attribute.


Call

if form.isvalid():
    # use cleaned_data

Jorge


>
>
> Anyway, its working now - thanks alot.
>
> btw... what is tuple? i am not native english speaker so i fail to
> understand some words like that.


It's a python data structure. It's an "" Array "" .


>
>
> Alan
>
> On May 17, 2:02 am, Daniel Roseman <roseman.dan...@googlemail.com>
> wrote:
> > On May 16, 10:51 pm, Alex Gaynor <alex.gay...@gmail.com> wrote:
> >
> >
> >
> > > On Sat, May 16, 2009 at 4:49 PM, zayatzz <alan.kesselm...@gmail.com>
> wrote:
> >
> > > > Hello
> >
> > > > Been trying to figure out where the problem is, but its almost 1am
> and
> > > > im out of ideas.
> >
> > > > i have this model:
> > > > class tuser (models.Model):
> > > >        username = models.CharField(max_length=20, help_text="Enter
> Username
> > > > of your account")
> > > >        email = models.EmailField(max_length=100, help_text="Enter
> your e-
> > > > mail address", unique=True)
> > > >        pwd = models.CharField(max_length=100, help_text="Enter your
> > > > password")
> > > >        active = models.SmallIntegerField(help_text="Different states
> of
> > > > activity - inactive, active...")
> > > >        joined = models.DateField(help_text="Date when registered")
> > > >        llogin = models.DateField(help_text="Date of last activity",
> > > > null=True)
> >
> > > > then i have this form:
> > > > class RegisterForm(ModelForm):
> > > >    class Meta:
> > > >        model = tuser
> > > >        fields = ('email')
> >
> > > > this is the view that handles the post:
> > > > def regattempt(request):
> > > >        if request.method == 'POST':
> > > >                form = RegisterForm(request.POST)
> > > >                if form.is_valid():
> > > >                        p = tuser(username=form.email,
> email=form.email,
> > > > pwd=randompass
> > > > (12), active = 1, joined = datetime.datetime.now())
> > > >                        p.save()
> > > >        else:
> > > >                form = RegisterForm()
> > > >        return render_to_response('authprof/register.html', {
> > > >                'form': form,
> > > >        })
> >
> > > > i've been trying to follow different examples like :
> >
> > > >
> http://docs.djangoproject.com/en/1.0/topics/forms/#processing-the-dat...
> >
> > > > The error i get is :
> > > > 'RegisterForm' object has no attribute 'email'
> >
> > > > Request Method:         POST
> > > > Request URL:    http://127.0.0.1/account/register/regattempt/
> > > > Exception Type:         AttributeError
> > > > Exception Value:
> >
> > > > 'RegisterForm' object has no attribute 'email'
> >
> > > > Exception Location:     /home/projects/tst/authprof/views.py in
> > > > regattempt, line 47
> >
> > > > line 47 is the p = tuser(so-on and so-forth....
> >
> > > > If anyone can explain me where this error comes from i would be very
> > > > happy.
> >
> > > > Alan
> >
> > > The issue is ('email') is  a string, and you need a tuple there, so it
> > > should have a comma: ('email',)
> >
> > > Alex
> >
> > Well, that's one issue. The other is that you can't refer to form
> > fields as attributes on the form instance. In fact, on the very link
> > that the OP gave, it shows the right way to do it:
> > p = tuser(username=form.cleaned_data['email']
> >                .... etc ... )
> > --
> > DR.
> >
>


-- 
neo2001[at]gmail.com
jorge[at]thecodefarm.com
neo[at]art-xtreme.com

--~--~---------~--~----~------------~-------~--~----~
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