Turn me into a Django Genius

From http://wiki.pyconuk.org/This%20is%20what%20we%20did

This session was an informal introduction to Django.

Python web apps really started with Zope, in like 1996. It was for making traditional desktop GUIs 'through the web;' and that never really went anywhere. Today its more Pythonic though, more modular. Zope is a restricted python runtime, security model, object database where every object has a URL… Plone is a layer atop, a CMS built on this stuff, which makes it really useful. Otherwise you'll need lots of boilerplate for doing things, espeically more standard things like relational-database kind of stuff. For CONTENT related tasks, Plone is very good, but not so good for apps. Plone is a good replacements for MS SharePoint actually. But Django is now very popular for Python web apps. For example, a status update system to show the good running of various systems on a network.

Django 1.1 came out August 2009. Debian ships 0.96 though.

Django has a file, models.py, with all the URLs that map to scripts that execute when the URL is called. These scripts call templates, crude HTML with some simple code. "MVC" framework; model is URLs… MVC idea doesn't map that well to the web, because its stateless. You can get use http://code.djangoproject.com/wiki/DjangoGraphviz to make a graphical representation of your model.py

Django's template is like what PHP 'should' have been, VERY SIMPLE programming contructs, so you cant have too much logic in the template. The smaller amout of code in the template the better.

<<<<<<< local Jinja2 is a more sophisticated template system you can use, same syntax but eg functions with multiple attributes. Aviva used this recently. But the restriction can help; Django prescribes a template engine, that cna be swpaped, while eg Pylons is very freeform. Logic in the 'view' isn't ideal, lots of projects have tried it and moved it away, and Django's is intentionally simple to push logic back up so designers can deal with templates and programmers can deal with code. Does that happen in the real world? Djang is from a small bed and breakfasts, and perhaps it's assumptions doesnt fit a large organisation style? But its 'best practice' as it allows a visual redesign that is sure not to break the logic.

<<<<<<< local Jinja2 is a more sophisticated template system you can use, same syntax but eg functions with multiple attributes. Aviva used this recently. But the restriction can help; Django prescribes a template engine, that cna be swpaped, while eg Pylons is very freeform. Logic in the 'view' isn't ideal, lots of projects have tried it and moved it away, and Django's is intentionally simple to push logic back up so designers can deal with templates and programmers can deal with code. bed and breakfasts Does that happen in the real world? Djang is from a small org, and perhaps it's assumptions doesnt fit a large organisation style? But its 'best practice' as it allows a visual redesign that is sure not to break the logic.

Jinja2 is a more sophisticated template system you can use, same syntax but eg functions with multiple attributes. Aviva used this recently. But the restriction can help; Django prescribes a template engine, that cna be swpaped, while eg Pylons is very freeform. Logic in the 'view' isn't ideal, lots of projects have tried it and moved it away, and Django's is intentionally simple to push logic back up so designers can deal with templates and programmers can deal with code. http://www.bnbstar.com bed and breakfasts Does that happen in the real world? Djang is from a small org, and perhaps it's assumptions doesnt fit a large organisation style? But its 'best practice' as it allows a visual redesign that is sure not to break the logic. >>>>>>> other >>>>>>> other

settings.py is for settings that are reusable in all your Django apps.

The most common app to write with it is a blog; Cal Henderson's djangocon (flickr founder) talk 2008 was about 'who wrote a wiki or blog engine with django?' One reason for this is the django admin screen; a nice and elegant web interface for administering your database, and this is dead good for development and where you dont care about usability; you can write your own UIs for simplifying things of course.

This network-status example has a Apache front and some URLs go to Django and some to Zope on the same domain (ProxyPass + ProxyPassReturn lines; no WSGI as not needed, apache URL rewriting is well known and stable). One Django app is a IT services status display, so you can see a map of the UK and a list of services and traffic light colors for how they are going. SVG map of UK (made with Inkscape) and librsvg renders it to PNG when the page is loaded.

How to learn?

Books: The 'Django book' is online, was good. 'Practical Django' is okay. The standard dissertation documentation is great! "Pro Django" is hardcore, lots of weird and wacky things you can do. "The Definitive Guide to Django" was by the founders and its for Django 1.1 and its good. Also, http://showmedo.com/ has a lot of video tutorials.

For graphs? Flotr, on google code, is a JS plotter tool - http://solutoire.com/flotr/

Now go back to http://wiki.pyconuk.org/This%20is%20what%20we%20did=======