Site icon JnPnote

Following Django Tutorial (CRM)-Part16

This post is for myself to remember how to build Django project.
I did follow the tutorial from the JustDjango Learn website free tutorial.
And this is the fourth tutorial named Getting Started With Django.
I am not going over all the details and descriptions for each part. There are good explanations on video of the JustDjango Learn. So, visit their site and try their tutorials if you need more details. Also, the orders of this post and their video might be different because I put things first what I think should come first.

I am doing this on Windows 10 with just Windows PowerShell. Not using virtual machines at all.

1. configuration for deployment

pip install django-environ
pip freeze > requirements.txt
import environ

env = environ.Env(
    # set casting, default value
    DEBUG=(bool, False)
)

READ_DOT_ENV_FILE = env.bool('READ_DOT_ENV_FILE', default=False)
if READ_DOT_ENV_FILE:
	environ.Env.read_env()

# False if not in os.environ because of casting above
DEBUG = env('DEBUG')

# Raises Django's ImproperlyConfigured
# exception if SECRET_KEY not in os.environ
SECRET_KEY = env('SECRET_KEY')
export READ_DOT_ENV_FILE=True
set READ_DOT_ENV_FILE=True
$env:READ_DOT_ENV_FILE="True"

2. set up postgresql

pip install psycopg2-binary
pip freeze > requirements.txt
createdb djangocrm
psql
psql postgres
CREATE USER admin WITH PASSWORD 'admin';
GRANT ALL PRIVILEGES ON DATABASE djangocrm TO admin;

3. Whitenoise

pip install whitenoise
pip freeze > requirements.txt
python manage.py collectstatic

done for this post

Exit mobile version