Install Django Development Environment On Ubuntu/Debian

Exported on 11-Oct-2021 12:32:14

Install Django Development Environment On Debian Based Server With AttuneOps

This Blueprint Installs Django Development Environment On Debian Based Server

Django is a Python-based open-source and free web framework that follows the model–template–views architectural pattern. It is maintained by an American independent, Django Software Foundation.

Django is a high-level Python web framework that encourages rapid development and clean, pragmatic design. Built by experienced developers, it takes care of much of the hassle of web development, so you can focus on writing your app without needing to reinvent the wheel.

Pre-Blueprint Attune setup
  1. On the Inputs tab, create a Linux node for the host you wish to install the stack on.
  2. On the Inputs tab, create Linux credentials to connect to the host you wish to install the stack on.
Steps Involved
  • Install yum repository.
  • Install Python version 3 and pip 3.
  • Setup Virtual Environment.
  • Install SQLite Database.
  • Install dependencies and launch development server.
Supported Operating Systems
  • Ubuntu
  • Debian

Parameters

Name Type Script Reference Default Value Comment
Linux Node Linux / Unix Server linuxNode
Linux User Linux OS Credential linuxUser

1 - Update APT Repository

Updates APT Repository

The connection details have changed from the last step.

Login as user on node

Connect via SSH
ssh user@hostname
This is a Bash Script make sure you run it with bash -l from a terminal session
# Update apt repositories
sudo apt -y update

2 - Install Python3 and Pip3

Installs Python 3 and latest PIP3 for Python package management

Login as user on node

Connect via SSH
ssh user@hostname
This is a Bash Script make sure you run it with bash -l from a terminal session
# Install python3
sudo apt-get install -y python3 python3-pip

3 - Install Virtual ENV

Installs Virtual ENV For Environment Management

Login as user on node

Connect via SSH
ssh user@hostname
This is a Bash Script make sure you run it with bash -l from a terminal session
# Install virtualenv
sudo pip3 install virtualenv

4 - Setup Virtual Environment

Creates a directory to store our Django application and sets up a virtual environment using Virtualenv

Login as user on node

Connect via SSH
ssh user@hostname
This is a Bash Script make sure you run it with bash -l from a terminal session
# Create django applications
mkdir django-apps
cd django-apps
virtualenv env

5 - Install Django

Downloads and Installs Django

Login as user on node

Connect via SSH
ssh user@hostname
This is a Bash Script make sure you run it with bash -l from a terminal session
# Install Django
sudo pip3 install django

6 - Setup Django Project

Creates a Django project and starts the development server in a screen session. The screen session can be accessed by running the command: screen -x

Login as user on node

Connect via SSH
ssh user@hostname
This is a Bash Script make sure you run it with bash -l from a terminal session
# Create Django project
django-admin startproject mysite

# Install screen package
sudo apt -y install screen

# Configure screen to run in background
sudo echo "zombie xy" >> ~/.screenrc

# Start development server
cd mysite
python3 manage.py migrate
screen -d -m python3 manage.py runserver