On Monday 14 Jul 2008, Rajesh Dhawan wrote:
> On Jul 14, 5:40 pm, Tim Sawyer <[EMAIL PROTECTED]> wrote:
> > On Monday 14 Jul 2008, Rajesh Dhawan wrote:
> > > The replace method here returns a new instance of a datetime object --
> > > it's not an in-place replace. This should work:
> > >
> > > self.datetime = self.datetime.replace(hour=23, minute=59)
> >
> > Hmm, that seemed to make sense to me too, though with my Java background
> > I wasn't sure.  I get:
> >
> > Exception Value:        'hour' is an invalid keyword argument for this
> > function
> >
> > on
> >
> > self.datetime = self.datetime.replace(hour=23, minute=59)
> >
> > self.datetime is defined as:
> >
> > datetime = models.DateTimeField()
>
> Strange...I just ran a few tests on a model field like that and it all
> worked perfectly.
>
> Can you dpaste your relevant code?
>
> Also, if you print type(self.datetime), do you get the type as
> datetime.datetime or something else?

Sussed it.

In my code, I did this:

self.datetime = pForm.cleaned_data['datetime']

the datetime parameter passed from the form only contained the date, with no 
time, so I assume the value in datetime then was only a date.

I've sorted my problem using the following code:

self.datetime = datetime(self.datetime.year, self.datetime.month, 
self.datetime.day, 23, 59)

Thanks for your help,

Tim.


--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to