How do I add functionality to all of my models without repeating myself?
See original GitHub issueI want to add a _d
attribute and a few classmethod
s and some regular methods to models by creating a subclass of tortoise.models.Model
that users of my framework can use. However, subclassing Model
would create a new database model, which is not what I want. From what I’ve seen, the Model
class contains a lot of logic, and it seems not feasible to create a new class with metaclass=ModelMeta
. What are my options here? Am I missing something?
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Keeping R code DRY with functions: Don't repeat yourself ...
Don't repeat yourself or the DRY principle is one of the best practices to writing good R. When you repeat the same block...
Read more >Using Marshmallow without repeating myself - Stack Overflow
Marshmallow doesn't allow your parent model to have a schema, so I don't have information on custom validations there.
Read more >Stop Repeating Yourself in Angular: How to Create Abstract ...
We have added some attributes and events shared by all text inputs, thus we will not have to add them again on our...
Read more >Don't Repeat Yourself - DevIQ
The Don't Repeat Yourself (DRY) principle states that duplication in logic should be eliminated via abstraction; duplication in process should be eliminated ...
Read more >~Don't~ Repeat Yourself - Hugging Face
Code for the attention mechanism is more or less copied over 50 times into different model files. Sometimes code of the whole BERT...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@tcmal Can you please check with release v0.12.4 ? new docs: https://tortoise-orm.readthedocs.io/en/latest/models.html#inheritence
Still doesn’t seem to work.