Posts tagged: DJANGO

dpaste.com update

My little pastebin site, dpaste.com, has been chugging along nicely since I announced it here about six weeks ago. Today I updated to the very latest Pygments codebase, which allowed me to add colorizers for Apache config files and bash scripts.

I’ve also started to add some Django-specific rules to the Python colorizer; it now recognizes Django model field types (model.CharField and the like). My thanks go to everyone who’s been using it, especially those who have given me feature suggestions and problem reports.

Django docs in Plucker format, nightly

It took me about a year to get around to it, but I finally set up that nightly cronjob to fetch the Django documentation into a Plucker file. (Note that if you don’t have a handheld with a Plucker reader, or aren’t closely following Django, this is of no use to you. Sorry. The intersection of those two sets is not very large.)

In addition to the current documentation pages, it includes the Trac Timeline, posts from the Community page, and the latest Django Book chapters. (Django team, let me know if I’m spidering anything I shouldn’t be.)

dpaste.com

I’ve re-launched my little Django-powered pastebin (formerly paste.e-scribe.com) under its own shiny new $8 domain name: dpaste.com. Not that the world really needs another pastebin, but people have been using it daily and it’s a fun side project. From the about page:

Philosophy: Simplicity and usability. The grayscale look makes the colorized source code stand out. Cookie-based personal defaults eliminate lots of extra form widgetry. Automatic expiry means the database never fills up. Auto-focus on the Code field means mouse-free operation. No required fields means you can paste, tab, return, and go. No running list of recent items means the spammers remain invisible. And Django makes nice clean URLs the path of least resistance.

The Django Book

Congratulations to Adrian and Jacob on the launch of their GFDL-licensed book on Django. From the Django blog:

This is a pre-release, which means we’re actively looking for comments, typo fixes, corrections and other suggestions from readers like you, all around the world. We’ll try to incorporate your suggestions into the final product, which will be published by Apress early next year. Amazon.com is accepting preorders for the print edition, and the number of preorders so far has been astounding.

Notes on my new Django setup

My personal record of using revision control for source code has been pretty spotty. Today I took steps toward fixing that by working out a system for managing my Django projects. I wanted revision control (Subversion), I wanted Django’s “runserver” for development and mod_python for deployment, and I didn’t want it to be a pain.

Some highlights of the process:

  • I used my pastebin site as the test mule. I checked in the current live site’s source code, created “trunk”, “tags”, and “branches” directories per the Subversion manual, and checked out a copy of the trunk into a staging directory.

  • I used svn propedit svn:ignore to keep the project’s SQLite database file out of the repository. Via my ~/subversion/config file I also ignore few other things such as .pyc files, just so that svn status checks aren’t littered with question marks on those files.

  • I created a simple runserver.sh script that sets $PYTHONPATH (so that imports like from pasteproject import settings find the staging version, not my deployed version!) and starts the Django development server.

  • Tricky Django thing #1: I use the conditional URLconf trick in order to correctly serve media files when using the development server. The docs on this trick go on to say; “the catch here is that you’ll have to remember to set DEBUG=False in your production settings file.” Which brings me to…

  • Tricky Django thing #2: Modular settings. The first line of settings.py is: from pasteproject.settings_local import DEBUG, TEMPLATE_DEBUG, PROJECT_BASE. The file settings_local.py is not under version control, and is of course different for the development and deployment versions. It’s only two lines; the first line sets DEBUG and TEMPLATE_DEBUG to True (development) or False (deployment); the custom setting PROJECT_BASE is used to locate the correct SQLite database file and the media files.