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
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
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
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
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
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,
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.
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
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
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
10 matches
Mail list logo