Thursday, October 28, 2010

adding field to query set

If I have such models

class Project(models.Model):
project = models.CharField(max_length=200)
user = models.ForeignKey(User) # user is from
django.contrib.auth.models => user

I would like to be able to display an an attribute that is made up of
first_name and last_name concatenated when i iterate the queryset

So in essence, can i create such sql from django without using cursor
class?

SELECT P.*, CONCAT(A.first_name, A.last_name)
FROM project P
LEFT OUTER JOIN auth_user A ON A.id = P.user_id

--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment