Re: sql query: how to

2010-09-27 Thread chris hendrix
yeah i was looking at something like that... actually let me correct what i'm needing to do: select year(fieldname) as pubyear from table order by year(fieldname) asc On 09/27/2010 01:15 AM, akaariai wrote: The most efficient? Exactly that using raw SQL. I think something along the followin

Re: sql query: how to

2010-09-26 Thread akaariai
The most efficient? Exactly that using raw SQL. I think something along the following will also work: Foo.objects.only('fieldname').value_list().distinct().order_by('fieldname'). - Anssi On Sep 27, 5:49 am, Bobby Roberts wrote: > what is the most efficient way to do the following sql command in

sql query: how to

2010-09-26 Thread Bobby Roberts
what is the most efficient way to do the following sql command in django? select distinct fieldname from table order by fieldname -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.co

Re: Query How To

2008-01-08 Thread Darthmahon
Ahh ok I saw that and thought it might be useful. Can I have more than one ManyToMany field in my custom user profile model? I.E. if a user has a list of songs and groups, for example? Just reading about ManyToMany - it seems to create an intermediary join table - is this exactly what I am trying

Re: Query How To

2008-01-08 Thread [EMAIL PROTECTED]
Another option is to create a user profile class (http:// www.djangoproject.com/documentation/authentication/#storing-additional-information-about-users), and have that user profile class have a ManytoManyField(http:// www.djangoproject.com/documentation/model-api/#many-to-many-relationships) with

Re: Query How To

2008-01-08 Thread Darthmahon
Hi Ivan, Thanks for the reply. Ok that makes sense, but I'm assuming I would then have to query the database again to get the name of that game for each result that is returned? This sounds like a lot of queries just to get a list - this is something I would usually handle by doing a JOIN query,

Re: Query How To

2008-01-07 Thread [EMAIL PROTECTED]
Something like this should return an iterable list of UserSong records for user U >>> list = UserSong.objects.filter( user=U ) Then you can iterate over it or pass that list to a template that iterates over it >>> for song in list: >>>doSomething Look here for more http://www.djangoproject.

Query How To

2008-01-07 Thread Darthmahon
Hey, My ongoing quest to get a basic app working will hopefully be answered by this question :) I have the following model.py file: File: model.py == from django.db import models from django.contrib.auth.models import User class Song(models.Model): titl

Re: OneToMany Connection quite simple query how to

2006-09-03 Thread limon
1. it should be (student__id=1) not (student_id=1) 2. i think grade should be the foreignkey of student, yours is just opposite --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this g

OneToMany Connection quite simple query how to

2006-09-01 Thread kelemen
Hi I have two simple models with a OneToMany connection class Student(models.Model): last_name = models.CharField(maxlength=60) first_name = models.CharField(maxlength=60) class Grade(models.Model): mark = models.CharField(maxlength=1, choices=MARK_CHOICES) student = models.Fore