Hi I am new to Django and building out a stock-control app as a learning tool.
I have a challenge I am struggling to understand which direction is the most correct to head off down to resolve this.
Scope:
I have two template views residing in two different applications of my overall project.
The first view is a Home Dashboard it has a series of small Dev panels that show various stats about the state of Stock volumes and other items of immediate interest to all Users, for example: Items in Stock, Available Products to order, Ordered Items, Low Stock Items, and finally Out of Stock Items. This view resides within my base app. These panels are dynamic and update as the Home Dashboard page is reloaded.
The second view is a CRUD page that allows an admin user to create and deleted stock items. This view resides in my Stock app.
Within this view is a filter panel that returns stock items based upon various criteria set. One of the filter options is low stock. Low stock is determined by comparing stock numbers (ints) to a variable (also an int) set from a dropdown in the filter panel itself, and thus this returns all rows of stock where the number of items is equal to or less than a number set by the low_stock dropdown.
I would like to have the low_stock variable as a Global variable which is set from the CRUD page in the stock app (so that only Admins can modify it). I’d then like that variable to stick as the application closes and opens. So that once it is set it will remain set until changed.
With this variable assessable to other views across all apps of my project, so that I can filter data and return that to any Dev item I want these filtered results displayed from.
My question is the following. Where should detail like this live:
-
in a Database table
-
As a custom Context Processor
-
As a variable in the Project settings.py file
-
Somewhere else.
I’ll only have a few of these Global variables within my entire site, so creating a database table to hold this detail seems over kill. I was hoping to keep the solution lighter if possible.
Advice and recommendations greatly appreciated.
Kind regards
Duncan