Django ORM Internals

184 views
Skip to first unread message

Mahdi Zareie

unread,
May 12, 2019, 7:47:42 PM5/12/19
to Django developers (Contributions to Django itself)

Hello everyone,

I got interested in contributing to the django project recently and I noticed lots of tickets are related to the ORM, I like to contribute to the ORM and close as many tickets as I can.
I started to read ORM related tickets and also checking related pull requests, since ORM is a big package and contains lots of modules, I found it very difficult to understand the changes in the pull requests.
Do you know any good resource about the internal structure of the django ORM? a blog post perhaps, anything to help me get started on the ORM internals.



J. Pic

unread,
May 13, 2019, 4:47:08 AM5/13/19
to django-d...@googlegroups.com
Hi Mahdi,

I would suggest reading the code and test code in the tests/ directory for the ORM.

There might also be some videos from Django Under The Hood conferences, found some here:


Best

Mahdi Zareie

unread,
May 13, 2019, 4:54:50 AM5/13/19
to Django developers (Contributions to Django itself)
Great, thanks

Adam Johnson

unread,
May 13, 2019, 6:16:47 AM5/13/19
to django-d...@googlegroups.com
Yes there isn't much documented on the ORM internals, but there are other resources. The DUTH videos are a great start and inspired me to get started contributing to Django. Specifically:
This talk is also on my to-watch list, from James Bennett, he covers a lot of internals:
As for looking through the code, try looking at django.contrib.postgres first - it's interesting as it's all *extensions* to the ORM (custom fields, migration operations, etc.) so an easier on ramp than diving into the inner code of Query etc. It's what insipred me to make my library django-mysql ( https://github.com/adamchainz/django-mysql ) that does the same kind of stuff for MySQL/MariaDB.

Then maybe look itno tracing some simple queryset operations, such as Foo.objects.all(), and see all the steps that goes through. Understand what Query is and how SQLCompiler converts it to SQL that the database backend executes.

Hope that helps,

Adam

--
You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-develop...@googlegroups.com.
To post to this group, send email to django-d...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/81554698-8fad-4fd0-a534-a566725058b3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--
Adam

Aymeric Augustin

unread,
May 13, 2019, 7:44:49 AM5/13/19
to django-d...@googlegroups.com
Hello,

I would suggest https://www.youtube.com/watch?v=bgV39DlmZ2U if you'd like to understand how the ORM is structured in layers.

-- 
Aymeric.


For more options, visit https://groups.google.com/d/optout.


--
Aymeric.
Reply all
Reply to author
Forward
0 new messages