1. 11/18/2008, 7PM
django-nyc
Will Larson
An intermediate
over view of useful
features.
charting django
(A map to avoiding that
“Where is the bathroom?”
“Under the sign.”
“Oh.”
feeling.)
2. qualifications
It’s all true. Damnit.
• Spent last year as English teacher.
• Last presentation was to 13 year olds.
• People skills. Damn it.
3. This presentation is
geared towards
django roadmap
advanced beginners, who
want a guide to become
intermediate
Djangonauts.
I hate that term.
• beginner - templates, views and urls
• intermediate - why you’re listening to me
• advanced - reusable applications
<img src=“funnyPicture.png”>Cats? Kids?</img>
4. Everyone needs three projects in their
django experience
trip towards Django mastery.
Don’t be afraid to start over from
scratch. When you make decisions
with insufficient knowledge is like
trying to get into a building when you
don’t know how to open doors.
Project a hole in Concept Status
You’ll probably have to blow
the wall, and even after you learn
about the door the hole is still going to
GalleryProject
be there.
gallery builder
LifeFlow blog engine
django-userskins user-specific skins
5. Almost all of this functionality
can be ignored, but by using it
• local_settings.py
your applications can be smaller,
more flexible, and much easier to
write. easy to feign mastery
Moving from beginner to adept is
• fixtures about increasing efficiency and
quality, not necessarily about
doing new things, but doing old
things better.
• template tags & filters
• management commands
• custom context
harder to feign mastery
• middleware
6. This is a common
convention, rather than
a feature.
It’s even harder to learn
convention than to learn
local_settings.py
features, because they’re
often undocumented.
• some project settings are location specific
• some are not
• Don’t Repeat Yourself
• => local_settings.py
8. local_settings.py in VC
• versioned:
• settings.py
• local_settings.py.template
• kitchen sink
• not versioned:
• local_settings.py
9. local_settings.py variant
This is how I roll.
Bringing settings
inheritance to the weary
developer/sys admin
• 2 + max(n,1) settings files hybrid.
• settings.py
• local_settings.py (not in version control!)
• ???_settings.py (deploy, devel, staging, etc)
local_settings.py
10. Can be used for initial and
fixtures
testing data, as well.
I use fixtures to maintain a
local copy of my blog, to
extract data to run
• export and import data statistics, and--sadly--I do
use it for simple migrations.
• extremely poor man’s schema migration
shell session
11. template tags & filters
• Don’t Repeat Yourself for templates
You’ve probably used the
default templates and
filters before. They’re
good, but sometimes you
run into missing
functionality.
Time to roll your own.
• use when justified
13. template tags, 1
• more powerful & complex than filters
Kevin t wittered about the “pyif”
templatetag. That’s a great example of
some_template.html
complex and powerful.
That’s because it’s mostly a wrapper
around the Python eval() function, i.e. it
is basically a templatetag that provides
direct access to the Python interpreter.
Model-View-Controller be damned, lets
throw the interpreter into the templates.
15. management commands
• periodic or one-time commands
• great with cron This is your primary
interface bet ween the
shell and Django, along
with:
python manage.py shell
17. custom context These really extend the usability
of generic views by letting you
inject arbitrary data into all
templates (well, all templates
• manage global information served by views that use
RequestContext, which includes
generic views).
• play nicely with generic views Try to keep them light weight to
avoid slowing down everything.
settings.py
19. middleware
• four levers to defy Django physics
• process_request This is a totally inadequate
introduction to middleware, which are
one of the more nuanced features of
• process_view Django.
You could have a 30 minute talk that
• process_response
solely focused on middleware and still
have questions left over and rocks
left unturned.
• process_exception This is a sketch of a sketch of a map,
but that’s all the time we have.
21. Visit my blog if you’re
interested in reading
about... stuff. Yeah, or don’t
visit it. That’s cool too.
What isn’t cool is how
smilely faces look in
Marker Felt.
• Irrational Exuberance @ http://lethain.com/
• django-monetize @ http://github.com/
lethain/django-monetize/tree/master/