Deploying Django App usig IIS Windows Server and MSSQL

Image

Deploying Django App usig IIS Windows Server and MSSQL

Feb. 5, 2024, 11:04 p.m.

Coding, Blog,

0 Comments

In this tutorial I will be creating a Single Page App using Django and deploy to Windows Server IIS and MSSQL for the Database. This is an actual project and I will be deploying it to our company. The idea is that, we are using a system called ServiceNow and in the even that the ServiceNow is down, using this SPA, we are able to lodge a request or an incident and once the ServiceNow is back online, we will create a powershell script to upload all dat a back to the ServiceNow. Im assuming your PC has already installed Python.

Steps to follow:

1. Setting up Virtual Environment - needed to isolate our dependencies. Open teminal or command prompt and run the following comands:

# Create a virtual environment named venv
python -m venv venv

# Activate the virtual environment
# On Windows
venv\Scripts\activate
# On macOS/Linux
source venv/bin/activate

 

2. Installing Django and Creating the Project - Now that your virtual environment is active, install Django and create a new project named SnowDown

pip install django
django-admin startproject SnowDown
cd SnowDown

 

3. Initial Run - Verify everything is set up correctly by running the development server:

python manage.py runserver
Visit 'http://localhost:8000' in your web browser to ensure the project is running successfully.

4. Creating the Incident App - Lets create aDjango App named Incidentdown fro handling incidents:

python manage.py startapp Incidentdown

 5. Setting Up Templates - Configure Django to recognized and use templates. Create a Template folder in the root directory and edit settings.py

# settings.py
TEMPLATES = [
    {
        'DIRS': [os.path.join(BASE_DIR, 'templates')],
        # ...
    },
]

6. Setting up Static Files - Similarly, set up static files by creating a 'static' folder in the SnowDown App. Update your project settings: 

# settings.py
STATIC_ROOT = os.path.join(BASE_DIR, 'static'')

STATIC_URL = '/static/'
STATICFILES_DIRS = [
    os.path.join(BASE_DIR, 'static'),
]


 

 

 

`
Leave a comment

Please Login or Sign Up to leave a comment.

0 Comments

No Comments Yet!

© TopITSolutions. All Rights Reserved.