Open adamcharnock opened 5 months ago
Vote goes to Option 3.
We basically do Option 3 with a hordak_source.TransactionSource
that joins hordak.models.Transaction
to other objects so we have a hard link on what generated a specific transaction/leg-set.
Thoughts Against Option 1
get_user_model()
.Leg
, Account
, Transaction
does the end user want to change? All 3 would need to be maintained as get_<model>_model()
.User
is to change logins from username
to email
, or change from first_name/last_name
to name
. There really isn't something applications need to fundamentally change. They all simply want to "extend". (I can agree maybe we're missing some helper functions like pos/neg Leg based on Account type, but that's not fundamental). So, monkey patch!Long winded to say - I agree =)
We've had some various requests which have boiled down to users needing to store extra data against Hordak models. Right now we just suggest users create their own model with a one-to-one relationship to the Hordak model. But it is worth considering other options.
Option 1: Allow extending the models
This is the same approach as Django's auth system, i.e.
USER_MODEL=...
, then callingget_user_model()
in your code. This gives the maximal flexibility, but I don't like it because:Option 2: Provide each model with an extensible field
Here we provide each model with a flexible field for extra data. For example, a
JSONField
calledextra
. I like this for its simplicity.I also think we could provide some quality-of-life settings around this data. For example, we could provide settings that allow users to add keys in the
extra
field to the admin filtering UI or search box. Plus users would still be free to create indexes as they desire in their own migrations.Option 3: One-to-one relationships (the status quo)
Users create their own model with a one-to-one relationship to the Hordak model.
Current thinking
I've come back to this issue as it is relevant to a project I am working on now. As a user of Hordak, option 3 seems to be actually the most appealing.
I may give it a go and see if I run into any issues.I've just updated my current project to use option 3 and it was much much better than the previous JSON-based approach (I was putting JSON in theLeg.description
field as a temporary hack).I'm therefore leaning heavily towards maintaining the status quo of option 3