All,

Got it working in the end - this is what I did:

_dob_year = int(form.clean_data['dob_year'])
_dob_month = int(form.clean_data['dob_month'])
_dob_day = int(form.clean_data['dob_day'])

_dob = date( year = _dob_year, month = _dob_month, day = _dob_day )

There probably is a cleaner way of doing it, but it seems to work :)

On Feb 16, 10:49 am, Darthmahon <[EMAIL PROTECTED]> wrote:
> Hi Alex,
>
> Tried this and it gave me the following error:
>
> TypeError at /register/
> an integer is required
>
> Any ideas?
>
> On Feb 13, 11:03 pm, Alex Koshelev <[EMAIL PROTECTED]> wrote:
>
> > You create string object with bits from form. But you have to make
> > date object. Example:
>
> > from datetime import date
> > _dob = date( year = form.clean_data['dob_year'],
> >                    month = form.clean_data['dob_month'],
> >                    day = form.clean_data['dob_day']
> >                       )
>
> > On 14 фев, 01:48,Darthmahon<[EMAIL PROTECTED]> wrote:
>
> > > Hi Alex,
>
> > > Not quite sure what you mean exactly. This is how that field is
> > > structured in my models.py file:
>
> > > birthday = models.DateField(blank=True)
>
> > > So it's already set as a datefield, but for some reason it seems as
> > > though my join is converting it into a string and Django doesn't like
> > > that.
>
> > > By the way, I am using Django 0.96 and MySQL.
>
> > > On Feb 13, 10:38 pm, Alex Koshelev <[EMAIL PROTECTED]> wrote:
>
> > > > If birthday UserProfile field in DataField you must set date object to
> > > > it. Not string.
>
> > > > On 14 фев, 00:50,Darthmahon<[EMAIL PROTECTED]> wrote:
>
> > > > > Hmm I seem to have hit another problem just after another!
>
> > > > > I've got a form that lets user's select the birthday via three
> > > > > dropdowns (day, month and year). This is all using newforms.
> > > > > Basically, within my views.py file I have a function that creates new
> > > > > users - one part of this process is to make sure the three dropdowns
> > > > > are joined together to create the timestamp so I can insert into the
> > > > > database.
>
> > > > > Here is this join:
>
> > > > > # join date back together
> > > > > days =
> > > > > [form.clean_data['dob_year'],form.clean_data['dob_month'],form.clean_data['
> > > > >  dob_day']]
> > > > > _dob = "-".join(days)
>
> > > > > # save user
> > > > > user =
> > > > > User.objects.create_user(username=_username,email=_email,password=_password
> > > > >  )
> > > > > user.save()
>
> > > > > # save custom profile
> > > > > user_profile =
> > > > > UserProfile(user_id=user.id,gender=_gender,birthday=_dob,living=_location)
> > > > > user_profile.save()
>
> > > > > However - what happens is I get this error:
>
> > > > > AttributeError at /register/
> > > > > 'unicode' object has no attribute 'strftime'
>
> > > > > Now I am sure it is referring to the join I am trying to do. I've
> > > > > tried wrapping unicode() around it but that didn't help either.
>
> > > > > Any ideas? I've had a look on here but can't see any solutions.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to