Ali,
As a general statement, the django ORM will return an entire instance of a model that you can then read values off of. To print the "total" field for each instance of the model with name "xyz" you would do:
for mm in MyModel.objects.filter(mobile_name='xyz'):
print mm.total
While thinking about the underlying sql can be useful,it can cloud how django ends up representing the data as models.
On Tuesday, December 24, 2013 10:12:27 AM UTC-6, Ali Hayder wrote:
-- As a general statement, the django ORM will return an entire instance of a model that you can then read values off of. To print the "total" field for each instance of the model with name "xyz" you would do:
for mm in MyModel.objects.filter(mobile_name='xyz'):
print mm.total
While thinking about the underlying sql can be useful,it can cloud how django ends up representing the data as models.
On Tuesday, December 24, 2013 10:12:27 AM UTC-6, Ali Hayder wrote:
Hi Russ MageeThanks for your answer. I am confused a little bit.I think "MyModel.objects.filter(mobile_name='xyz')" line of code is like "SELECT * from table-xyz WHERE mobile_name=xyz" but I was looking for the alternative of "SELECT total FROM tablexyz WHERE mobile_name=xyz"Thanks in advance
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/a0c4cdee-8032-423e-b098-2276872df29b%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
No comments:
Post a Comment