Skip to content

Instantly share code, notes, and snippets.

@23maverick23
Last active August 29, 2015 14:21
Show Gist options
  • Save 23maverick23/3a94cf4f2e3cabbceeab to your computer and use it in GitHub Desktop.
Save 23maverick23/3a94cf4f2e3cabbceeab to your computer and use it in GitHub Desktop.
Django: How to start working on your project

Django 1.8 & PostgreSQL 9.4

The following are actual (suggested) steps for starting to work on a Django/PostgreSQL project. It does not cover configuring the settings of your app and database. It serves more as a reminder for what to do to get your app back up and running for development.

Step One

Activate your Python virtual environment (you are using one, right?). Then, make sure you change directories into your top-level project directory.

$ workon kanban
$ cd ~/path/to/project

Step Two

Start the PostgreSQL server on the default port. If you have lunchy installed, you can use 2 alternate commands.

# without lunchy...
$ pg_ctl start -D /usr/local/pgsql/data

# with lunchy...
$ rvm use default
$ lunchy start postgresql

Step Three

Start the Django app.

$ python manage.py runserver

Step Four

When you're done with any development or testing, be sure to stop both servers. Django can be stopped using Ctrl+c.

# without lunchy...
$ pg_ctl stop -D /usr/local/pgsql/data

# with lunchy...
$ lunchy stop postgresql

If you add any information to your models that will need to change your database structure, you will need to use the new "migrate" feature.

# create a migration file...
$ python manage.py makemigration

# migrate your database changes...
$ python manage.py migrate
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment