Groups
Groups
Sign in
Groups
Groups
Django users
Conversations
About
Send feedback
Help
Conver sql to orm django
18 views
Skip to first unread message
jose alejandro hernandez rosales
unread,
Jun 16, 2014, 2:49:45 PM
6/16/14
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to django...@googlegroups.com
Hi , everyone i have a little problem, how do I convert this sql sentence to ORM?
SELECT * FROM CLIENTS
LEFT JOIN rutas ON
clientes.ruta_id = rutas.ID
LLEFT JOIN repartidores ON
clientes.ruta_id = repartidores.ruta_id
Erik Cederstrand
unread,
Jun 17, 2014, 2:41:04 AM
6/17/14
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Django Users
This should work:
Client.objects.select_related('ruta').prefetch_related('ruta__repartidores')
But you should really post your model code so we can see how the foreign key and many-to-many relations are defined.
Erik
Reply all
Reply to author
Forward
0 new messages