On Apr 10, 6:55 pm, Malcolm Tredinnick <malc...@pointy-stick.com>
wrote:

> However there could be, and likely are, many TextChar objects with the
> same edition value, so it would be ambiguous as to which particular
> object to return. Since there's no natural choice, there's no API to ask
> Django to guess or provide a sample object or anything like that. It's
> not appropriate to return a model object for that type of query.
>
> What is the real problem you are trying to solve here? Why do you need
> an object back?

Well, I want to display in a template the name of the edition, rather
than the primary key, which means nothing to the user.  Meanwhile I
resorted to do the footwork in the view function like so, which allows
me to achieve what I need:

reslist = [{'edition' :Edition.objects.get(pk=a['edition']).__unicode__
(), 'count': a['char__count']} for a in char.textchar_set.values
('edition').annotate(Count('char'))]

Thanks for the help anyway!

All the best,

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

Reply via email to