Related Objects
I have a case in which I need to return only 1 field from the related
object (table).
The docs give an example where I can return the related object in a
query, but I need only one field from the related object.
For Example:
I retrieve all the customers from the 'Customers' table. Each
customer has many projects associated. (I am writing a project
management system)
I am using a template where I have an html table which lists all the
customers (column 1), and then the number of projects associated with
the customer (column 2)
Customer | Number of Projects
---------------------------------------------------
customer 1 | 4
customer 2 | 5
I can see clearly from the docs how to retrieve the entire projects
table (from the foreign key), but I would be wasting resources by
retrieving the entire table (mostly feeling like I am throwing data
all over the place unnecessarily)
I hope I have described the problem clearly. Thank you in advance for
any help you can give.
--
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.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home