How do I manage my models in Django, is there an equivalent to a database diagram in VS Code?

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

It doesn't require VSCode, but django-extensions is a package that generated ERDs using GraphViz 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:

print(Models.objects.all().query)
>> SELECT 'name', 'blablabla', 'something' FROM db_something
Back to Top