skip to Main Content

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


  1. It doesn’t require VSCode, but django-extensions is a package that generates ERDs using GraphViz under the hood.

    You can see details here.

    Login or Signup to reply.
  2. 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
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search