django-schema-viewer is an open-source Python package designed to help Django developers visualize and navigate their database models with ease. By automatically generating graphical representations of Django models and their relationships, this tool simplifies the process of understanding complex database structures, making it an essential asset for any Django project.

Utilizing django-schema-viewer in your Django projects provides several benefits that can greatly improve your development experience. First and foremost, it offers improved comprehension of the database schema by presenting graphical representations of the various models and their relationships. This visual layout makes it easier to understand the complex connections between different data elements.

Incorporating django-schema-viewer into your development workflow can significantly improve your ability to manage and maintain complex Django projects, leading to more efficient and effective database designs.

What is django-schema-viewer?

django-schema-viewer is an open-source Python package designed to generate graphical representations of Django models and their relationships automatically. It simplifies the process of understanding database structures by providing a clear and interactive visual interface, making it easier to navigate and manage complex data schema.

The primary purpose of django-schema-viewer is to help Django developers save time and effort when working with intricate database designs. By offering a visual representation of the data relationships, this tool enables developers to quickly grasp the project's database structure and make informed decisions regarding schema modifications and optimizations.

The ongoing development and maintenance of this tool ensure that it remains compatible with the latest versions of Django and various databases, providing an up-to-date and reliable solution for visualizing Django database schemas.

Features and Capabilities

django-schema-viewer offers a wide range of features and capabilities designed to simplify the process of visualizing and managing Django database schemas.

Graphical representation of Django models

One of the primary features of django-schema-viewer is its ability to generate graphical representations of Django models and their relationships automatically. This feature allows developers to quickly grasp the structure of the database and identify any potential issues or areas for optimization:

  1. Automatic schema generation: django-schema-viewer automatically generates visual representations of your Django models based on the existing database schema. This feature saves developers time and effort when creating diagrams manually.
  2. Customizable visual layouts: The visual layouts generated by django-schema-viewer are fully customizable, allowing developers to tailor the appearance of the diagrams to their preferences. This customization capability enables users to create clear and easily readable representations of their database structures.

Interactive user interface

django-schema-viewer provides an interactive user interface that makes it easy to navigate and explore complex database schemas:

  1. Zooming and panning: The interface includes zooming and panning functionality, enabling users to focus on specific areas of the diagram and navigate large schemas with ease.
  2. Search functionality: The search feature allows developers to quickly locate specific models or fields within the diagram, making it easier to find and analyze relevant information.

Compatibility with various databases

django-schema-viewer supports a wide range of databases, including:

  • PostgreSQL
  • MySQL
  • SQLite
  • Oracle
This compatibility ensures that django-schema-viewer can be used with various Django projects, regardless of the underlying database system.

Installation and Setup

In this section, we will guide you through the process of installing and setting up django-schema-viewer in your Django project.

To install django-schema-viewer, follow these steps:

Using pip: Open your terminal or command prompt and run the following command to install the package via pip:

pip install django-schema-viewer

Adding to Django projects: After installing django-schema-viewer, add it to your project's INSTALLED_APPS setting in the file:

    # ...
    # ...

Once you have installed and added django-schema-viewer to your project, you can configure its settings to meet your specific requirements.

Setting up URLs: To integrate django-schema-viewer make sure to include the following URL patterns in your project's file:

from django.contrib import admin
from django.urls import path, include

urlpatterns = [
    # ...
    path('schema/', include('schema_viewer.urls')),
    # ...

Configuring Optional Settings: In the file of your Django project, you can further customize the behavior of django-schema-viewer using optional settings. Two particularly useful optional settings are 'apps' and 'exclude'.

  • 'apps': This setting allows you to specify a list of Django apps that should be included in the generated schema. By default, django-schema-viewer includes all apps in your project. However, you can limit the displayed apps by providing a list of the apps you want to include, like this:
    'apps': [

In this example, only the contenttypes and my_app apps will be included in the generated schema.

  • 'exclude': This setting enables you to exclude specific models from the generated schema. You can specify the models to exclude on a per-app basis. For instance:
    'exclude': {
        'auth': ['User'],
        'my_app': ['SomeModel'],

In this example, the User model from the auth app and the SomeModel model from the my_app app will be excluded from the generated schema.


Run the following command to start the Django development server:

python runserver

Once the server is running, open your web browser and enter the following URL:
Replace with your server's address and port if necessary.

After accessing the URL, you should see the django-schema-viewer interface, which displays a graphical representation of your Django models and their relationships. Here's an example screenshot of what you might see:

Screenshot of Django-schema-viewer

This screenshot displays the graphical representation of the Django models, their associated tables, and fields.

The visual layout helps you understand the relationships between the different models in your project.


In this article, we delved into the capabilities of django-schema-viewer, a powerful and intuitive tool that assists Django developers in visualizing and navigating their database models more effectively. By offering graphical representations of Django models and their relationships, it provides numerous benefits and use cases that can greatly enhance the development experience.

As your Django project evolves, django-schema-viewer helps streamline the maintenance process by keeping track of changes in the database structure. This simplification makes it easier to maintain and refactor the schema as needed, ultimately saving time, effort, and resources while improving the overall quality of your Django projects.

Given the numerous advantages and capabilities of django-schema-viewer, it is an indispensable tool for any Django developer working with complex database schemas.

Thank you for reading and I will see you on the Internet.

This post is public so feel free to share it.

If you like my free articles and would want to support my work, consider buying me a coffee:

Are you working on a project that’s encountering obstacles, or are you envisioning the next groundbreaking web application?

If Python, Django, and AI are the tools you're exploring but you need more in-depth knowledge, you're in the right place!

Get in touch for a 1-hour consultation where I can address your specific challenges.

Developer Service Blog - 1 Hour Consulting - Nuno Bispo
Are you working on a project that’s hitting roadblocks or simply dreaming up the next big web application?

Tagged in: