Skip to content

lab-flow/backend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Hazardous Reagents backend

This repo contains code for the backend written in Django and PostgreSQL.

Requirements

  • Python 3.9.16
  • PostgreSQL 15.4

Python 3.12.1 with Django 5.0 was also tested in a dev/test environment but not in production.

Configuration

  1. Create a virtual environment (e.g. venv). Activate it and upgrade pip with pip install --upgrade pip.
  2. Install all required dependencies with pip install -r requirements.txt. Alternatively, use the script for Linux or for Windows which will install the latest available packages.
  3. Add every required environmental variable, that is:
    • from the settings file:
      • SECRET_KEY: the secret key required by Django (more details here)
      • PG_NAME, PG_USER, PG_PASSWORD, PG_HOST, PG_PORT: the database settings (more details here)
    • from the generators module; they indicate paths to .ttf files with specified font types:
      • REGULAR_FONT
      • BOLD_FONT
      • ITALIC_FONT
  4. Create a PostgreSQL database.
  5. Run python manage.py migrate to create tables and relations in the database.

Dev/test environment

  1. Set the DEBUG variable in the settings file to True.
  2. In the settings file add appropriate IP addresses to CORS_ALLOWED_ORIGINS (more details here).
  3. Run a dev/test server: python manage.py runserver

Deployment

  1. Pick an HTTP server (e.g. httpd with mod_wsgi). It will be used to serve both the app and the media (Django doesn't do that by itself).
  2. In the settings file add appropriate IP addresses to CORS_ALLOWED_ORIGINS (more details here).
  3. Go through the deployment checklist.
  4. Deploy the app to the web server.

Running tests

Run python runtests.py.

Some useful commands

  • Create an admin user: python manage.py createsuperuser
  • Clean duplicate history records: python manage.py clean_duplicate_history --auto
  • Make a migration: python manage.py makemigrations reagents
  • Show available URLs: python manage.py show_urls

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages