On Tue, 2009-03-03 at 03:41 -0800, A Melé wrote:
> I tried to add a custom attribute to the objects in the query_set of a
> custom Manager before returning the query_set but it seems not to
> work:
>
> class SongManager(models.Manager):
> def expire(self):
> from boto.s3.connection import S3Connection
> c = S3Connection()
> for song in self.get_query_set():
> song.new_attribute = c.generate_url(expires_in=10000,
> key=song.mp3.name, method="GET")
> return self.get_query_set()
You keep retrieving a new queryset here. Fetch the queryset once, modify
it and then return that instance:
qs = self.get_query_set()
for song in qs:
...
return qs
Regards,
Malcolm
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---