Django: Difference between revisions
(Created page with "Easiest to install with pip: <pre>sudo aptitude install python3 pip3</pre> Once it's installed, go to a project directory (not where you want the project): <pre>django-admi...") |
No edit summary |
||
Line 18: | Line 18: | ||
<pre>ALLOWED_HOSTS = ['sam','sam.bpopp.net']</pre> | <pre>ALLOWED_HOSTS = ['sam','sam.bpopp.net']</pre> | ||
To configure django for MySQL, use the following in settings (make sure they python MYSQL module is loaded): | |||
<pre> | |||
DATABASES = { | |||
'default': { | |||
'ENGINE': 'django.db.backends.mysql', | |||
'NAME': 'd_django', | |||
'USER': 'dbuser', | |||
'PASSWORD': 'password', | |||
'HOST': '127.0.0.1', | |||
} | |||
}</pre> |
Revision as of 18:22, 14 April 2018
Easiest to install with pip:
sudo aptitude install python3 pip3
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', } }