No edit summary
No edit summary
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
Easiest to install with pip:
Easiest to install with pip:


<pre>sudo aptitude install python3 pip3
<pre>sudo aptitude install python3 python3-pip
sudo pip3 install Django
sudo pip3 install Django
</pre>
</pre>
Line 31: Line 31:
         'PASSWORD': 'password',
         'PASSWORD': 'password',
         'HOST': '127.0.0.1',
         'HOST': '127.0.0.1',
        'OPTIONS': {
            'init_command': "SET sql_mode='STRICT_TRANS_TABLES'",
        },
     }
     }
}</pre>
}</pre>

Latest revision as of 18:28, 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',
        'OPTIONS': {
            'init_command': "SET sql_mode='STRICT_TRANS_TABLES'",
        },
    }
}

To apply any database migrations, run:

python3 manage.py migrate