Stack Name - Django

Synopsis

The is the base reusable implementation for a Django type tech stack.  Django is an open source project delivering a high-level Python Web framework that encourages rapid development with pragmatic design.   The primary goal of the project is to ease the creation of complex, database-driven websites.

The core features of the framework are:

  • a lightweight and standalone web server for development and testing
  • a form serialization and validation system that can translate between HTML forms and values suitable for storage in the database
  • a template system that utilizes the concept of inheritance borrowed from object-oriented programming
  • caching framework that can use any of several cache methods

The Harbormaster Django tech stack contains the necessary templates and macros to generate a fully functional Django project complete with a vendor specific YAML pipeline file in order to install Django and the necessary dependencies to build, test, and deploy the resulting application.

Details

Authordev@harbormaster.ai
AccessPublic
Derived From.python.tech.stack
Long NameDjango
Short NameDjango
Language(s)Python, Javascript, YAML, HTML, XML, Velocity Macros
Git Urlhttps://github.com/Harbormaster-AI/techstacks/tree/main/Django
Example Project YAMLhttps://github.com/Harbormaster-AI/cli/blob/main/samples/yamls/project.as.code/django-project-as-code.yml

Contents

Along with what is supported by the parent tech stack (.python.tech.stack), the following are overridden and additional capabilities:

  • App Related:
    • Contains the templates used to generate the Django Models, Views, Urls, Tests, and Data Delegates for each entity found within a Harbormaster supported model.
  • Core:
    • Contains the application settings, URL mappings and main entry point to run the app.
  • Macros/Model:
    • Velocity macros used to assist in creating certain file outputs

Usage

If using a CI/CD platform such as CircleCI, AWS Codebuild, Jenkins, etc.., it is best to refer to the Pipeline YAML file generated for that platform.

If not using a CI/CD platform refer to the instructions below on how to use the generated project.

To get started manually

The following instructions assume Python is installed. If not, learn how to install Python here.

pip Installation

pip install --upgrade pip

pipenv Installation

pipenv is a virtual environment for Python projects.

pip install pipenv

Install Django

Install Django into a virtual environment.

pipenv install
pipenv install Django==2.0

Install Pytest-Django

pytest-django is a plugin for pytest that provides a set of useful tools for testing Django applications and projects.

pipenv install pytest-django

Run Test

pipenv run pytest --junitxml=test-results/junit.xml ${appName}/tests

Creating a Built Distribution

python ${appName}/setup.py sdist

Run Django Migrations

python manage.py makemigrations
python manage.py makemigrations polls
python manage.py migrate

Start a Local Web Server

python manage.py runserver

The application is now accessible via browser at:

http://localhost:800