I’m learning Django and my models are getting complex. The FK and PK relationships are doing my head in.
I’m used to create database diagrams with SSMS in MS SQL Server, is there anything equivalent to this in SQLite?
I’ve tried a number of VS code extensions, such as ERD Editor, ERD Preview and even just simple diagram tools such as draw.io
The problem with them is there is no integration with the DB so or the classes in models.py
2
Answers
It doesn’t require VSCode, but
django-extensions
is a package that generates ERDs usingGraphViz
under the hood.You can see details here.
You can use Pycharm and execute your SQLite there, it’ll open a interface that will allow you to interact with the database.
If you find hard to understand the models and wants to see the raw queries (a representation, because it’s not valid output to execute directly in the Django) when you’re using queryset, you can see this FAQ.
Sometimes I use .query like this: