views:

197

answers:

3

Hello,

I am developping a django app on Windows, SQLite and the django dev server . I have deployed it to my host server which is running Linux, Apache, FastCgi, MySQL.

Unfortunately, I have an error returned by the server on the prod while everything ok on the dev machine. I've asked my provider for a pre-production solution in order to be able to debug and understand the problem.

Anyway, what are according to you the most likely errors that can happen when moving a django app from dev to prod?

Best

Update: I think that a pre-prod is the best way to address this kind of problem. But I would like to build a check list of what must be done before to put in production. Thanks for the very valuable answers that I received until now :)

Update: FYI, I 've implemented the preprod server and the email notification as suggested by shanyu and I can see that the error comes from the smart_if templatetag that I am using on this new version. Any trick with template tags?

Update: I think I've fixed the pb which was caused I think by the Filezilla FTP sending. I was using the "replace if newer" option which I guess is causing some unexpected results. Using the "replace all" option fix the issue. However, it was an opportunity for me to learn more about deployment. Thansk for your answers.

+7  A: 

Problems I typically have include:

  1. Misconfigured productions settings, whether in my production localsettings.py, wsgi/cgi, or apache site files in /etc/sites-available
  2. Database differences. I use South for migrations and have run into some subtle issues when performing my migration on PostgreSQL when it worked smoothly in sqlite.
  3. Static file hosting since I cheat and use the Django server in development
  4. Permissions, both on the file system and within the database
  5. Rare, but possible, network issues preventing me from getting my dependencies, whether on PyPi or some 3rd party site

Ways that I have mitigated these issues:

  • Use the same database in production and development (in your case, MySQL everywhere)
  • I've found it is useful to have a "test" environment which mimics production in every way possible (it can be on lower end hardware, or even the same machine). This way, if there are any issues in this "production-like" enivornment, I can solve them without taking my production server offline.
  • Script everything for repeatable deployments. I use fabric, but zc.buildout or Paver would also work. These tools help reduce typos while deploying and reduce the time to deploy my app.
  • Use version control (mercurial, git, subversion) and a schema migration tool (like South), so if something does go wrong when you deploy to production, you have the possibility of backing out the changes and allowing production to run on the old code with the old database schema.
  • I haven't set up an "egg proxy" yet, but I am considering it, to avoid issues when downloading dependencies.
  • I've found pip's freezing dependencies to be useful, in case a new, incompatible change to a library occurred since I downloaded it initially
  • Use a web testing framework like Windmill or Selenium to test my application in my "test" environment, so that I can get a lot of test coverage of my system very quickly.
John Paulett
Very interesting answer. I am going to look at carefully
luc
+1  A: 

Regarding your case, I can think of 2 simple things that may help you:

  1. You can enable Django to send messages when exceptions occur giving details about them. Look at here for details.
  2. You'll be better off if you set up a test environment on the prod server (say, test.example.com) so that you can check if things will go smoothly or not before you deploy the app.
shanyu
Thanks for these 2 tips. I didn't know that #1 is possible. I agree that a pre-prod environment is what I need
luc
I've implemented both of them and it is very useful tools. See my update
luc
Glad to be of help. I suggest you settle this question and ask another one for the smart if tag issue as it is off topic.
shanyu
A: 

I believe these were the podcasts I listened to recently (from Pycon 2009):

Locate Django in the Real World (PyCon 2009):

http://advocacy.python.org/podcasts/pycon.rss

Parts 1 to 3

Very good introduction to designing your apps for deployment, in particular for reuse and redeployment.

Regs.

Adam