How to use variables in django models.py, (DEFAULT properties of fields)

I would like that, when clicking on one of the companies below, a variable is stored (until the browser is closed) with the company's code.

enter image description here

And, I need this variable to populate the 'CompanyCode' fields as default value.

FOR EXAMPLE:

class Employee(models.Model):
class Meta:
    db_table = 'employee'

CompanyCode= models.IntegerField(
    null=False,
    blank=None,
    default = 'VARIABLE',
    db_column='CompanyCode'
)

After being stored in the database, I need to make a query to show all tuples where CompanyCode is equal to a certain value.

Could someone tell me a python, django component that I could use to separate the data for each company? I thought of using JavaScript Local Storage at first.

Back to Top