I have seen the answers to both parts of my question, but how can I marry them? / P>
I have a book model and a translated message.
The translated book is a common language established in the form of model choice:
LANGUAGES = ((U'it ', U' Italian '), (Uja' , You 'japani'), (you''s, you 'spanish'), (you's-cn ', you're Simplified Chinese' ', (you's-tw', u 'trademark sugar'), ( You ',' you ',' you ', you' greq '(u', 'you' arabi '), (u'bug', u 'bubbles'), (you'bin', u 'Purple'),
etc.
I know that to get "Italian", book me on book object .get_language_display
But how do I get a list of different languages in my long form?
I have tried:
lang_avail = TargetText.objects.values ('language'). Different () .order_by ('language') lang_avail = TargetText.objects.distinct () .order_by ('language'). Value ('language' ). Lang_avail = TargetT ('language'). ('Language')
But I think what I want - it's not what's a list:
< P> "English, Italian, Simplified Chinese, Spanish"The last long_wales listed above have a list of 5 Did not return, he returned the list of 355 (i.e., # books) with many repetitions ....
- Edit -
Daniel got almost the answer I received - As it is revealed, that throws a "dicks unreliable" error Thanks to the Digicon IRC on Acic, we instead use Daniel's solution with this line:
Langs = TargetText.objects.values_list ('language', flat = true) .distinct (). Order_by ('language')
and it works
There is no built-in method. You can do something like this:
lang_dict = dict (LANGUAGES) langs = TargetText.objects.values ('language'). Specific (). Order_by ('language') long_langs = [lang_dict [Lang] langs langs]
which easily creates a dictionary of one LANGUAGE
options and then every language ID is visible.
Comments
Post a Comment