Reputation: 279
I am designing a Django project, where I need the following (I want to implement something more complex, but simplified here):
Table: work_order
Columns: owner_id,
...,
contract_file_id (maps to 'all_files.id')
Table: labour_license
Columns: owner_id,
...,
license_file_id (maps to 'all_files.id')
Table: all_files
Columns: id (UUID4Field),
category (CharField,
'contract' if linked to 'work_order.contract_file_id',
'labour_lic' if linked to 'labour_license.license_file_id')
file (FileField)
...
work_order
, it should insert a row in all_files
with category='contract'
; similarly for labour_license
.owner_id
(in work_order
table if all_files.category='contract'
; similarly for labour_license
.I have literally 10s of file fields like this, and I would like to write some kind of Mixin or custom Field, or even a metaclass if required, which I can use for all such file fields. If it is possible, would appreciate some ideas or directions I can look into.
Upvotes: 0
Views: 27