>
> I realize very often, that I have to decide between using the object
> (s) i.e.
> Pic.objects.get(id=1)
> or the dict that values() returns me, see
> Pic.objects.get(id=1).values()
>
> I have to decide either/or because sometimes I have some additional
> data,
> I want to add to the dict, before passing it to the template. In that
> case it
> makes most sense to use values(), i.e.
> p = Pic.objects.get(id=1).values()
> p["extra_value"] = some_calculation(p)
> I could also do that by implementing the some_calculation() as a method
> of Pic, but sometimes that is only a one time case and shouldnt go in
> the
> main object.
> That again prevents me form calling the object's methods inside the
> template
> since I only have a dict of the values :-(
>
> Anyone got a nice trick for enhancing the object's data just for use
> in a certain template/view?
What about:
p = Pic.objects.get(id=1)
p.extra_value = some_calculation(p.values())
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---