3 ms·
The other funny thing is how easy it is to write migrations in Python via the RunPython capabilities of the Django ORM you can migrate data over. I've yet to ne
by giancarlostoro 6y ago
The other funny thing is how easy it is to write migrations in Python via the RunPython capabilities of the Django ORM you can migrate data over. I've yet to need to write any SQL aside from stored procedures and Database Views.
You can even export all the contents of your DB to JSON or YAML and import it in Django, so you probably very well could go from SQLite to MySQL / Postgres if you really wanted to.
Edit:
The other actually funny thing is, Django doesn't force you to use its own ORM. You can write code that doesn't use its ORM. You can override anything and everything.
- jordic 6y agoFor me it's too much easy to write them with sql or plpgsql.. and later I can use them from node, rust, go.. or whatever.. for me the dB (the model) it's the source of thruth that will lasts.. independent of the language that interacts with it... Also the problem gets worst if you add to the mix something like elastic search. That it also has it's own schema and it's also has to be migrated..
- bb88 6y agoBut now you've got the issue that the code needs to match the DB. Django takes care of this for you. It's really quite nice.
- jordic 6y agoThat's the trade-off if you decouple the dB from the web framework you have to take care of both.. :) anyway, I prefer to trust the dB (real data on it) that a bunch of complicated things on the Django side.. (I suspect that happened something similar to me when I started reviewing crazy (shoot your food) class based elaborations..
- giancarlostoro 6y agoYou can always tell Django's ORM not to manage any of your data and write all your queries. You can also tell Django to give you the query it generates, tweak it (if / as necessary) and run from there.
- bb88 6y agoBut why? Granted if you have super complex queries, sure. But 95-99% of the queries are simple typically.
- rurp 6y ago> how easy it is to write migrations in Python via the RunPython capabilities of the Django ORM you can migrate data over. Yes! This functionality is extremely useful in a number of cases and isn't all that discoverable. At least in my experience, devs often don't learn about it until they've spent at least a bit of time working on a Django project. Once you get the (basic) syntax down it's quite handy.
- kissgyorgy 6y ago> You can write code that doesn't use its ORM. You can, but what's the point using Django then? Everything is built around the ORM API, that's how admin is automatically generating pages, etc, etc. You lose the main advantage of Django if you don't use it.
- giancarlostoro 6y agoASP .NET Has the same issue, but you could always override the admin bits. If you really want another library to manage Django's database usage, you can go to town, nobody has bothered coding alternatives because the ORM is sufficient. Web frameworks are not what you use if you're even concerned with micro managing how you access a database, web microframeworks on the other hand are designed for that level of detail. Something like CherryPy or Flask is more what you'd want in that case.