Re: Sometimes datetime sometimes date?

2009-06-15 Thread Daniel Roseman

On Jun 16, 3:34 am, Streamweaver  wrote:
> sqlite3
>
> I changed the method and it seems to be working now.
>
> The code I'm using is:
>
> def all_last_updated(self):
>         d = [self.last_updated, self.activity_set.latest
> ().last_updated]
>         d.sort()
>         d.reverse()
>         return d[0]
>
> There seemed to be some problem when chaining sort().reverse() before.
>
> Not sure I understand it still and attributing it to me missing
> something in general but it's working now.

The problem is that sort() doesn't return anything, it sorts in-place.
So you can't chain it, as reverse() acts on the return value of the
previous function, which is None.

Although I can't understand why you got the error you did, I would
expect the error 'NoneType' object has no attribute 'reverse'.
--
DR.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: Sometimes datetime sometimes date?

2009-06-15 Thread Streamweaver

sqlite3

I changed the method and it seems to be working now.

The code I'm using is:

def all_last_updated(self):
d = [self.last_updated, self.activity_set.latest
().last_updated]
d.sort()
d.reverse()
return d[0]

There seemed to be some problem when chaining sort().reverse() before.

Not sure I understand it still and attributing it to me missing
something in general but it's working now.

On Jun 15, 10:08 pm, Ramiro Morales  wrote:
> On Mon, Jun 15, 2009 at 10:34 PM, Streamweaver wrote:
>
> > I ran into what I think might be a bug and wanted to check here before
> > possibly posting it.
>
> > Essentially what seems to be happening is that Django seems to return
> > datetime.datetime or datetime.date from DateFields in models and I
> > can't figure out why it returns one type at one time and another type
> > at another.
>
> What database are you using?
>
> --
> Ramiro Moraleshttp://rmorales.net
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: Sometimes datetime sometimes date?

2009-06-15 Thread Ramiro Morales

On Mon, Jun 15, 2009 at 10:34 PM, Streamweaver wrote:
>
> I ran into what I think might be a bug and wanted to check here before
> possibly posting it.
>
> Essentially what seems to be happening is that Django seems to return
> datetime.datetime or datetime.date from DateFields in models and I
> can't figure out why it returns one type at one time and another type
> at another.

What database are you using?

-- 
Ramiro Morales
http://rmorales.net

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