4 ms·
The example shows that django models uses metaclasses heavily. So I'm assuming if you needed to extend django models, you'd have to do it via metaclasses.
by stuckinhell 4y ago
The example shows that django models uses metaclasses heavily.
So I'm assuming if you needed to extend django models, you'd have to do it via metaclasses.
- carapace 4y agoToo easy: Django meta-programming is one of the things that has bitten IRL. A junior dev was pulling hair out one day trying to subclass a Django HTML form object. Couldn't do it because of Django cowboy metaclass. Had to wrap it in a "factory" and modify it before returning it. Django using metaclasses is exactly the problem I'm warning of... You don't need metaclasses for data models nor for HTML forms. Nothing Django does requires metaclasses, and it's actively beginner-unfriendly to use them.
- mixmastamyk 4y agoWhat is an example of a good orm alternative? Don’t remember sqlalchemy being substantially different on the model definition front.