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.

One contribution to “Django snips

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

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>