Running Python 3.7 Django App service Linux on Azure
In this blog I’m creating Django app with Python 3.7 image from Azure Web App on Linux
- Create an app and open visual studio code
-
Create requirements.txt with below content
django==2.1.2
-
Make sure you create virtual env from Python 3.7 version
python.exe -m venv venv

-
After creating it…Activate venv as below
.\venv\Scripts\activat.bat

-
Install requirements.txt
pip install -r requirements.txt

-
Check if Django is installed correctly
python -m django –version

-
Do django-admin startproject <somename> that creates auto-generate code to start Django app with
django-admin startproject mydjangoapp

- Replace application.py content with below (In line 6 “your djangoapp.settings”)
- Source:https://github.com/gangularamya/AzurePythonDjangoWAFL/blob/master/application.py

- Include Allowed hosts in settings.py file

- Navigate to Azure Portal.
- Create Web App on Linux.

- Setup Continuous Deployment or Use local git to push your code to azure.

- You can find a sample Python Django project with above operations @GitHub Link
SERVING STATIC FILES:
- Add whitenoise plugin to serve static files on Azure.
https://pypi.org/project/whitenoise/
https://devcenter.heroku.com/articles/django-assets
- My Sample output with static file.
