Replies: 5 comments
-
I agree that the current solution is not as DRY as it should be. However, I haven't found any generic solution yet, which is flexible enough as adding this kind of boilerplate to every Collection. For the typical 1:n-relation ( |
Beta Was this translation helpful? Give feedback.
-
Here's a gist of a collection class for relations + factory functions: https://gist.github.com/Actionb/243e5ff9e56c715f1439d95ed6401fd6) |
Beta Was this translation helpful? Give feedback.
-
Thanks, I will have a look at it. |
Beta Was this translation helpful? Give feedback.
-
@Actionb I believe to have found a generic solution. Please check the Please check branch releases/1.0.x |
Beta Was this translation helpful? Give feedback.
-
That looks good to me. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
There seems to be a lot of repetition when using collections for model relations. I think a collection class specially for relations that implements generic
model_to_dict
andconstruct_instance
methods would be a good addition:For example, for adding
aliases
to a band:You would use a
RelatedCollection
like this:Using this, a
related_collection_factory
function would be possible, too. And from that, a collection factory for entire models?Beta Was this translation helpful? Give feedback.
All reactions