Django Notes:


Install virtualenvwrapper
pacman -S python-virtualenvwrapper
export WORKON_HOME=~/.virtualenvs
source /usr/bin/

mkvirtualenv -p /usr/bin/python2 my_env
virtualenv --no-site-packages -p /usr/bin/python2 udemy-py-django-scratch
Create a virtualenv with python2

workon my_env
source my_env
Activate the virtualenv

(my_env)$ pip install django
(my_env)$ easy_install django
Install django in the virtualenv

(my_env)$ deactivate
Leave the virutalenv startproject django_test
Start a new project by creating startup files

python2 runserver
Test the project with webserver

python runserver 8080
Start the development server on another port

python2 startapp article
Start a new app (module) called article

./ makemigrations
Makes new migrations (updates)

python2 syncdb
Updates database with new data

python2 reset article
Removes a table schema and data from the database

python2 collectstatic
Grabs all static directories and info and registers them

python shell
Allows you to import local modules from the current app you are
using as if they are part of python.

Then you can run:

from article.models import Article
To show all articles

from django.utils import timezone
Pull timezone from django settings (used below)

a = Article(title="Added from shell", body="oh yeah!",, likes=0)
Add info from the shell
Save info just added
Show id of article just added

Show all articles in shell