Skip to content

Instantly share code, notes, and snippets.

@calumroy
Last active August 29, 2015 14:05
Show Gist options
  • Save calumroy/3f48e132da2235bed51e to your computer and use it in GitHub Desktop.
Save calumroy/3f48e132da2235bed51e to your computer and use it in GitHub Desktop.
Django basics

##virtual env

workon hpflask

pip install -r path/to/requirements.txt

##manage.py

###Runserver ./manage.py runserver

###Postgres

Start postgres if its not already running

python manage.py migrate

python manage.py syncdb

Terminal psql

   psql

connect to database

   \c

create database

   create database databasename;

List database entries

   \l

Quit

   \q

Drop(delete a table) Sometimes this needs to be done before you can migrate to another database

   drop table hpflsk_event;

Create postgis extension

   CREATE EXTENSION postgis;

###Run tests ./manage.py test

Run tests from a specified file

./manage.py test hpflsk/tests/test_user.py

or a specified class

hpflsk/tests/test_user.py:TestUser.test_user

###Nose Tests http://ivory.idyll.org/articles/nose-intro.html

###Heroku

##Django Shell

    python manage.py shell

Now you can run commands on your test server.

##Test Server After starting the server got to http://127.0.0.1:8000/ login

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment