Django snips

A few things I found useful on the way:

Serving static files from the dev server

I eventually gave up trying to serve media from the dev server and setup a Debian VM to set up a production style environment. However, later I came across the following thing to add to urls.py:

 (r'^media/(?P<path>.*)$', 'django.views.static.serve', {'document_root': '/path/to/your/media/'}),

Flatpages quirk

If flatpages don’t seem to work (i.e. you get a 404 even when you’ve added one), check this user group email, it could be the site ID in your settings doesn’t match the ‘sites’ ones in the DB.

Updates to production DB

Advice from the IRC channel (thanks to ‘Kurushiyama’):

  1. make a backup of your prod data
  2. make a structure dump with drops of your devel data
  3. import this structure into prod
  4. import your prod backup into prod db

There should be a script for doing exactly that in “code”. If you add required fields, you have to edit your data dump manually or set a reasonable default.

Last modified: July 15, 2008

One Contribution to “Django snips”

  1. Kurushiyama wrote:

    Actually there is a problem:
    If you add required fields, you have to edit your data dump manually or set a reasonable default

Contribute to this article:

NB: Posting a comment means that you agree to the comments policy.

NB: Your email will not be shown, published or used.

Allowed HTML tags: a, acronym, strong, code, em, blockquote, ul, ol, li.