Thursday, December 22, 2016

Installing Django

This is an incredible pain to figure out.  Dependencies - python 3.5, and don't forget to set up virtualenvs...whatever those are.  Don't get me wrong: I've done plenty of python, but never really wanted to deal with something that complicated.

The goal here is to get django installed.  Stretch goals, dealt with later, are a) to get django-based website running locally and b) to do lots of cool pythonic things in the background.

Based on further exploration of how these things work, I am amazed how complicated this is.  And the documentation is basically written for someone with complete conceptual understanding of the software, who just forgot the commands they need.  Not that beginner-friendly.

Sources

Dependencies

Make sure python is installed. And the other stuff.
sudo apt-get install python3.5
sudo apt-get install python-pip
sudo pip install virtualenv

Create your virtualenv (src)

Apparently, it's good to store your virtualenvs all in the same place.  The recommended location is ./.virtualenvs, so that's what we'll use.
mkdir ~/.virtualenvs
python3 -m venv ~/.virtualenvs/myfirstdjangowebsite
Note: if you're using ubuntu, that last command might not work.  If it doesn't, you'll have to make sure the python3 versions of everything are installed and then use a different form of the command.
sudo apt-get install python3-pip
sudo pip3 install virtualenv
virtualenv --python=`which python3` ~/.virtualenvs/myfirstdjangowebsite
Now activate the virtualenv.  If the first command doesn't work, use the second.  Remember: you have to activate the virtualenv in every new terminal window.
source ~/.virtualenvs/myfirstdjangowebsite/bin/activate
. ~/.virtualenvs/myfirstdjangowebsite/bin/activate

Install Django

Once that virtualenv is set up, install django.
pip install Django 
Django is now available within the virtualenv you set up.

No comments:

Final post here

I'm switching over to github pages .  The continuation of this blog (with archives included) is at umhau.github.io .  By the way, the ...