Here are some examples:
Filter: SELECT * FROM device WHERE locked = true - returns a QuerySet
which can be evaluated as a list of Device objects
Get: SELECT * FROM device WHERE id = (value of id variable) LIMIT 1 -
returns a single Device object
All: SELECT * FROM schedule - returns a QuerySet which can be evaluated as
a list of Schedule objects
These are only approximations. For example, get() does not imply a
"LIMIT", since Django looks for cases where multiple objects were returned
and throws an exception. But hopefully this helps you understand how the
ORM maps to SQL queries.
Here's the relevant part of the documentation [1], in case you haven't
found it yet.
Brett
1. https://docs.djangoproject.com/en/dev/topics/db/queries/
On 11/3/11 11:40 PM, "Ganesh Kumar" <bugcy013@gmail.com> wrote:
>Hi,
>
>I'm a new to Django. I know mysql queries.
>I cant understand django queries, Basically My understanding
>complicated to the django queries. please guide me.
>
>Device.objects.filter(device_id = device_id)[0]
>Device----->table
>device------>column
>
>Device.objects.filter(locked = True)
>
>Device.objects.get(device_id = id)
>
>Schedule.objects.all()
>
>filter method what type 0f content return.------> equivalent sql quires
>get method what exactly doing-------> equivalent quires
>all method what exactly doing ---------> equivalent sql quires
>
>
>please guide me..
>
>-Ganesh
>Did I learn something today? If not, I wasted it.
>
>--
>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.
>
--
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