so I have been playing around with django for a bit and I really do like this framework. However, I would like to understand better how it actually works 'under the covers'.
Here is my current view of client-server-django world, which is very rough and will probably make your toenails curl (sorry)...
Ok, so what the heck is my question you ask? Well, how does this all work, really? I am not expecting that you spoon-feed me everything... I suspect that the answer will ultimately be to "read the source, luke", however, I would be grateful if
thanks a lot Paul
Starting a Django project allows you to build your application's entire data model in Python without needing to use SQL. Using an object-relational mapper (ORM), Django converts traditional database structure into Python classes to make it easier to work within a fully Python environment.
Django's primary deployment platform is WSGI, the Python standard for web servers and applications. Django's startproject management command sets up a minimal default WSGI configuration for you, which you can tweak as needed for your project, and direct any WSGI-compliant application server to use.
Django, being a web framework, needs a web server in order to operate. And since most web servers don't natively speak Python, we need an interface to make that communication happen. Django currently supports two interfaces: WSGI and ASGI.
Well, your first misconception is that CGI has anything to do with this. It doesn't, except very unlikely and little-used server configurations.
Mostly, Django interfaces with the server via WSGI, which is a Python specification for web servers to talk to web applications. You can see more information at the WSGI website.
Apart from that, the whole request/response cycle is very well described by James Bennett in his blog entry here. It's quite old, but little has changed in Django at that level since it was written.
Watch James Bennett's Django in Depth tutorial from Pycon 2015.
From the Pycon website, here's the abstract of James' talk:
Most books, tutorials and other documentation for Django take a high-level approach to its components and APIs, and so barely scratch the surface of the framework. In this tutorial, however, we'll take a detailed look under the hood, covering everything from the guts of the ORM to the innards of the template system to how the admin interface really works.
Whether you're the newest of newbies or the most seasoned of application developers, you'll come away with a deeper knowledge of Django, and a plethora of new tips and tricks you can use in your own applications.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With