Tuesday, February 12, 2008

Configure a Django project

Here's how to create and configure a new Django project with a mySQL database on Mac OS X:


  1. Create the project. This one is easy. CD into the directory that will hold the directory for your code. Then type in:
    django-admin.py startproject 
  2. Edit settings.py All of the configuration settings are in settings.py. All of the ones at the top that start with DATABASE are the ones you want to touch. The biggie is DATABASE_ENGINE. Set it to this, for mysql:
    DATABASE_ENGINE = 'mysql'
    At the bottom, is INSTALLED_APPS. This setting includes (or removes) extra applications for your project. Take out anything you don't need.
  3. Test the db. To test the database, run the syncdb that creates the database from the models.py and settings:
    python manage.py syncdb
  4. Test the server. If that worked, test the included server:
    python manage.py runserver

Yay! It works!

No comments: