Below the code you just paste at the bottom of the settings.py file copy the following code which is related to static file that will be served in production environment:

# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.10/howto/static-files/
# The absolute path to the directory where collectstatic will collect static files for deployment.
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
# The URL to use when referring to static files (where they will be served from)
STATIC_URL = '/static/'

Install Whitenoise locally via the terminal:

pip3 install whitenoise

In the settings.py file, at the MIDDLEWARE setting and add the WhiteNoiseMiddleware below the SecurityMiddleware (it is the second line shown in the code below: 'whitenoise.middleware.WhiteNoiseMiddleware',).

Re-test the site locally to make sure it wasn’t affected by any changes we have made.

python3 manage.py runserver

Visit http://localhost:8000 and make sure everything works properly within the application.

Step 5 – Deploying on Heroku

Create a Heroku account. Login and go to the dashboard. Install Heroku client for you operating system (more details at https://devcenter.heroku.com/articles/getting-started-with-python#set-up). Check if the client is correctly installed by running the following command in the terminal:

heroku help

Create and upload the web application.

heroku create

If you specify a value after create then that will be the name of your application. See example below: