Re:Taming the beast that is the Django ORM – An introduction
by BarryMilo on Sunday September 01, 2024 @01:17AM
(#41414490)
Aren't Django models close enough to types?
Re:Taming the beast that is the Django ORM – An introduction
by wg0 on Sunday September 01, 2024 @01:31AM
(#41414546)
Nope. Python type hinting is far far from Java like types.
And yes, I guess OP has now a large system that needs types enforced by the system to reduce the friction in evolving the stack.
Re:Taming the beast that is the Django ORM – An introduction
by roze_sha on Sunday September 01, 2024 @01:33AM
(#41414560)
What about using pydantic?
Re:Taming the beast that is the Django ORM – An introduction
by mehdix on Sunday September 01, 2024 @02:02AM
(#41414677)
FWIW, one python project I'm working on uses an obscure Framework, and ORM. I was contemplating to convert it to FastAPI+Pydantic, however the amount of effort needed was no different than rewriting the whole project.
Re:Taming the beast that is the Django ORM – An introduction
by LtWorf on Sunday September 01, 2024 @07:11AM
(#41415915)
pydantic + sql database?
So have 2 components that ensure the types are correct? Why?
Re:Taming the beast that is the Django ORM – An introduction
by winrid on Sunday September 01, 2024 @02:22PM
(#41419028)
I already use type annotations with Python for use within my IDE. It's just all tiring garbage. Java is already almost a scripting language and I can actually use a shared heap, etc. also I have some core code in java I use in the desktop app I want to reuse in the server. Right now I transpile that core code to TS and then JS to use client side, but I'd rather just have everything in Java.
Re:Taming the beast that is the Django ORM – An introduction
by Izkata on Sunday September 01, 2024 @02:13PM
(#41418951)
If this is what you're referring to:
> Note: The Python runtime does not enforce function and variable type annotations. They can be used by third party tools such as type checkers, IDEs, linters, etc.
Then yes, Django model definitions are more like Java types in that they error if you try to use an incorrect type. You can't just ignore them like with type hints.
They also try to be 1:1 with database types, so for the most part any additional validation added on top of Django would be something you had to do anyway.
I'm rewriting a large Django project in Java (quarkus + jooq), because it's at the point where I need a type system now, but it still has a place in my heart.