Thanks, this is a very interesting way. I will give a try. Cheers, Alan
On Mon, Dec 29, 2008 at 04:48, join.toget...@gmail.com < join.toget...@gmail.com> wrote: > > In your model definition, you can specify choices for each field. > http://docs.djangoproject.com/en/dev/topics/db/models/#field-options > > Create a list of (DB value, display value) tuples containing all the > choices, then set the field's "choices" option to that list. > > Later, when you have your model instance, you can call > "instance.get_junit_display()" to obtain the "4 magenta" etc for > display or whatever else you would need it for. > > On Dec 25, 4:28 pm, Alan <alanwil...@gmail.com> wrote: > > Hi List, Merry Xmas! > > > > In my mysql db, I have this table (ccpngrid_gridjob), created from a > model > > GridJob: > > > > | juser | jname | title | fileName | jdate | jobdir | jstatus | jpid | > jiter > > | round | > > > > where my pk is jobdir. > > > > I would like to know how to convert, if possible, the sql command below > to a > > django query: > > > > select *, case > > when jstatus='Submitted' then '1 orange' > > when jstatus='Running' then '2 blue' > > when jstatus='Failed' then '3 red' > > when jstatus='Cancelled' then '4 magenta' > > when jstatus='Finished' then '5 green' > > else '6 black' end as seq > > from ccpngrid_gridjob where juser='alan' > > order by seq, jobdir DESC > > > > Many thanks in advance. > > > > Alan > > > > -- > > Alan Wilter S. da Silva, D.Sc. - CCPN Research Associate > > Department of Biochemistry, University of Cambridge. > > 80 Tennis Court Road, Cambridge CB2 1GA, UK. > > > > >>http://www.bio.cam.ac.uk/~awd28<< > > > -- Alan Wilter S. da Silva, D.Sc. - CCPN Research Associate Department of Biochemistry, University of Cambridge. 80 Tennis Court Road, Cambridge CB2 1GA, UK. >>http://www.bio.cam.ac.uk/~awd28<< --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---