django-dbsettings
django-dbsettings copied to clipboard
ForeignKey value
I was wondering whether it wouldn't be possible to have a setting holding a foreign key, or a reference to some model.
The use case is that I have a model defining a collection of objects, of which a single one can be active in the application at any time. I need to switch there in a setting.
WIlling to propose a PR if the maintainer doesn't object to it by design.
I'd suggest to store the PK of the selected object (as a string) and have a custom logic that retrieves this dbsetting and fetches the actual entity. Would that work for you?
I was thinking more of leveraging the contenttypes framework: https://docs.djangoproject.com/en/3.0/ref/contrib/contenttypes/