We will now create a settings file for your project, on the server.
Let's try this time to do it manually, with an editor.
The settings file should look something like this:
ALLOWED_HOSTS = ["myproject.mydomain.com"]
SECRET_KEY = ''
# Send error reports to:
ADMINS = (
('Your Name', '[email protected]'),
('John Doe', '[email protected]'),
)
# send some other reports to...
MANAGERS = ADMINS
Edit this file locally in an open editor. Add a secret key to the text above. If your project has django-extensions
, to generate a secret key, run locally :
python manage.py generate_secret_key
Or use an online tool.
Connect to your server and use either nano
or vim
to edit MyProject/myproject/local_settings.py
:
ssh [email protected]
nano MyProject/myproject/local_settings.py
Paste the file content there, save and exit (Ctrl+X with nano).
Use Ctrl+D to logout from ssh.
To check if your project is set up correctly use check
:
@task
def m(cmd, pty=False):
with virtualenv():
run(f"./manage.py {cmd}", pty=pty)
@task
def check():
m('check')
@task
def send_test_mail():
m('sendtestemail --admin')
run:
fab check
fab send_test_mail
(Note: The mail will most probably get into your spam folder. We will later configure your server to be whitelisted by popular mail servers.)