Where can i get the technical manuals/details of how django internals work, i.e. i would like to know when a request comes in from a client;
? etc...
Paul.G
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.
You can cache output of your specified views as per your need , or cache those views which are difficult to produce , or you can even cache the entire site . So this was the workflow of Django , i.e how these components interact with each other and makes Django a powerful Web Development Framework.
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.
Besides reading the source, here's a few articles I've tagged and bookmarked from a little while ago:
I've found James Bennet's blog to be a a great source for information about django workings. His book, Practical Django Projects, is also a must read -- though it isn't focused on internals, you'll still learn about how django works.
"Use the source, Luke." The beauty of open source software is that you can view (and modify) the code yourself.
Easiest way to understand the internals of django, is by reading a book specifically written for that.
Read Pro Django. It provides you a good in depth understanding of the meta programming first and demonstrates how it is used in django models, to create them dynamically.
It deals similarly with many other python concepts and how django uses it.
Simply reading the source might be a bit overwhelming, especially since the upper-most part is a bit confusing (how the webserver hands off the request to Django code). I find a good way to get started reading the code is to set a debugger breakpoint in your view function:
def time(request):
import pdb; pdb.set_trace()
return HttpResponse(blah blah)
then hit your URL. When the debugger breaks at your breakpoint, examine the stack:
(Pdb) where
c:\abcxyzproject\django\core\management\commands\runserver.py(60)inner_run()
-> run(addr, int(port), handler)
c:\abcxyzproject\django\core\servers\basehttp.py(698)run()
-> httpd.serve_forever()
c:\python25\lib\socketserver.py(201)serve_forever()
-> self.handle_request()
c:\python25\lib\socketserver.py(222)handle_request()
-> self.process_request(request, client_address)
c:\python25\lib\socketserver.py(241)process_request()
-> self.finish_request(request, client_address)
c:\python25\lib\socketserver.py(254)finish_request()
-> self.RequestHandlerClass(request, client_address, self)
c:\abcxyzproject\django\core\servers\basehttp.py(560)__init__()
-> BaseHTTPRequestHandler.__init__(self, *args, **kwargs)
c:\python25\lib\socketserver.py(522)__init__()
-> self.handle()
c:\abcxyzproject\django\core\servers\basehttp.py(605)handle()
-> handler.run(self.server.get_app())
c:\abcxyzproject\django\core\servers\basehttp.py(279)run()
-> self.result = application(self.environ, self.start_response)
c:\abcxyzproject\django\core\servers\basehttp.py(651)__call__()
-> return self.application(environ, start_response)
c:\abcxyzproject\django\core\handlers\wsgi.py(241)__call__()
-> response = self.get_response(request)
c:\abcxyzproject\django\core\handlers\base.py(92)get_response()
-> response = callback(request, *callback_args, **callback_kwargs)
> c:\abcxyzproject\abcxyz\helpers\views.py(118)time()
-> return HttpResponse(
(Pdb)
Now you can see a summary of the path from the deepest part of the web server to your view function. Use the "up" command to move up the stack, and the "list" and "print" command to examine the code and variables at those stack frames.
I doubt there are technical manuals on the subject. It might take a bit of digging, but the API documentation and the source code are your best bets for reliable, up-to-date information.
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