Skip to main content

A simple Django app to manage a bill of materials.

Project description

BOM

BOM is a simple Django app to manage a bill of materials. It supports multiple part numbering schemes, tracking component sourcing information, estimates costs, and contains smart integrations with Mouser to pull in the latest component pricing and Google Drive for part file management. BOM is written in Python 3 and Django.

See a live example.

BOM can be added to an existing (or new) Django project, or stand alone on its own, which can be more convenient if you're interested in tweaking the tool.

If you already have a django project, you can skip to Add Django Bom To Your App, otherwise Start From Scratch: Add to new Django project to add it to a new django project, or Start From Scratch: Use as standalone Django project.

Table of contents

Start From Scratch: Add to a new Django project

  1. Create and activate a virtual environment (Python 3.10+):
python -m venv .venv
source .venv/bin/activate   # Windows: .venv\Scripts\activate
  1. Install Django and set up your project:
pip install django
django-admin startproject mysite
cd mysite
python manage.py migrate
python manage.py createsuperuser # make a user for your development environment
  1. Continue on to Add Django Bom To Your App.

Add Django Bom To Your App

django-bom is a reusable django application. If you don't already have a django project, you can follow some quick steps below to get up and running, or read about creating your first django app here.

pip install django-bom
  1. Add "bom" to your INSTALLED_APPS setting like this::
INSTALLED_APPS = [
    ...
    'bom',
    'social_django', # to enable google drive sync in bom
    'djmoney', # for currency
    'djmoney.contrib.exchange', # for currency
    'materializecssform',
]
  1. Update your URLconf in your project urls.py like this::
path('bom/', include('bom.urls')),

And don't forget to import include:

from django.conf.urls import include
  1. Update your settings.py to add the bom context processor 'bom.context_processors.bom_config', to your TEMPLATES variable, and create a new empty dictionary BOM_CONFIG.
TEMPLATES = [
    {
        ...
        'OPTIONS': {
            'context_processors': [
                ...
                'bom.context_processors.bom_config',
            ],
        },
    },
]

and

BOM_CONFIG = {'standalone_mode': False}
  1. Run python manage.py migrate to create the bom models.

  2. Start the development server python manage.py runserver and visit http://127.0.0.1:8000/admin/ to manage the bom (you'll need the Admin app enabled).

  3. Visit http://127.0.0.1:8000/bom/ to begin.

Start From Scratch: Use as a standalone Django project

  1. Clone the repo and create a virtual environment:
git clone https://github.com/mpkasp/django-bom.git
cd django-bom
python -m venv .venv
source .venv/bin/activate   # Windows: .venv\Scripts\activate
  1. Install dependencies and start the server:
pip install -e .
cp bom/local_settings.py.example bom/local_settings.py
python manage.py migrate
python manage.py runserver

Customize Base Template

The base template can be customized to your pleasing. Just add the following configuration to your settings.py:

BOM_CONFIG = {
    'base_template': 'base.html',
}

where base.html is your base template.

Integrations

Mouser Integration

For part matching, make sure to add your Mouser api key. You can get your key here.

Google Drive Integration

Make sure to add the following to your settings.py:

AUTHENTICATION_BACKENDS = (
    'social_core.backends.google.GoogleOpenId',
    'social_core.backends.google.GoogleOAuth2',
    'social_core.backends.google.GoogleOAuth',
    'django.contrib.auth.backends.ModelBackend',
)

SOCIAL_AUTH_GOOGLE_OAUTH2_SCOPE = ['email', 'profile', 'https://www.googleapis.com/auth/drive', 'https://www.googleapis.com/auth/plus.login']
SOCIAL_AUTH_GOOGLE_OAUTH2_AUTH_EXTRA_ARGUMENTS = {
    'access_type': 'offline',
    'approval_prompt': 'auto'
}

And if you're using https on production add:

SOCIAL_AUTH_REDIRECT_IS_HTTPS = not DEBUG

FIXER

Fixer.io is used to handle exchange rate calculations. This is helpful if you may be purchasing parts from another currency (especially via Mouser) and you still need to estimate your part costs.

To set this up you just need to add your API key to local_settings.py as shown in the example.

To update rates, migrate and run python manage.py update_rates. Some day we will need to add a (celerybeat?) task to update rates on a schedule. Explained more here.

Contributing

Contributions welcome! Before contributing your work please read the contributing readme.

Also reach out to mike@indabom.com to discuss features, and join our slack channel.

Installation Pitfalls

Windows

Sqlite

You may get an error during your pip install -r requirements.txt related to sqlite. This may be fixed by installing Visual C++ for python...

Cryptography

Sometimes you'll have issues installing cryptography, if this is the case you may just need to set up some environment variables. This stackoverflow may help.

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django_bom-1.288.tar.gz (487.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_bom-1.288-py3-none-any.whl (565.8 kB view details)

Uploaded Python 3

File details

Details for the file django_bom-1.288.tar.gz.

File metadata

  • Download URL: django_bom-1.288.tar.gz
  • Upload date:
  • Size: 487.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for django_bom-1.288.tar.gz
Algorithm Hash digest
SHA256 95ef613c24b132932697192e033047b2cb647d61be305f50e1e4e26a0c87649e
MD5 99f589bde60c6d504d11bd17393bac0b
BLAKE2b-256 51836d07546bb08dd6126997b7891edfd823697de5d99b98e26367926a481f79

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_bom-1.288.tar.gz:

Publisher: publish.yml on mpkasp/django-bom

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file django_bom-1.288-py3-none-any.whl.

File metadata

  • Download URL: django_bom-1.288-py3-none-any.whl
  • Upload date:
  • Size: 565.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for django_bom-1.288-py3-none-any.whl
Algorithm Hash digest
SHA256 7c9206f2c260f370fdb805d3cfcc65ba9bcd0b8c8ee3202f61541962c6bfebb6
MD5 5fde8423747156675a418ec1eee24ccb
BLAKE2b-256 e288c879a8929b199fdfe2ffe13f7226d1cbc6f6e025902f45b55ddded59cf6f

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_bom-1.288-py3-none-any.whl:

Publisher: publish.yml on mpkasp/django-bom

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page