No edit summary
No edit summary
Line 1: Line 1:
Easiest to install with pip:
Easiest to install with pip:


<pre>sudo aptitude install python3 python3-pip3
<pre>sudo aptitude install python3 python3-pip
sudo pip3 install Django
sudo pip3 install Django
</pre>
</pre>

Revision as of 18:24, 14 April 2018

Easiest to install with pip:

sudo aptitude install python3 python3-pip
sudo pip3 install Django

Once it's installed, go to a project directory (not where you want the project):

django-admin startproject hello

CD into that directory and then run:

python3 manage.py runserver 0.0.0.0:8000

The 0.0.0.0 is optional, but required in order to access remotely. If you are accessing it remotely, you'll also need to modify settings.py and add the hostname to "ALLOWED_HOSTS":

vi ./hello/settings.py

And then:

ALLOWED_HOSTS = ['sam','sam.bpopp.net']

To configure django for MySQL, use the following in settings (make sure they python MYSQL module is loaded):

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'd_django',
        'USER': 'dbuser',
        'PASSWORD': 'password',
        'HOST': '127.0.0.1',
    }
}

To apply any database migrations, run:

python3 manage.py migrate