DEV Community

Victor Ribeiro
Victor Ribeiro

Posted on

2 2

Split your Django generated models into separated files

Split Django Models

Split Django generated models into separated files, with proper names, classes and imports.

Usage

Generate your models:

python3 manage.py inspectdb > models.py

Run the script:

./split_django_models.sh models.py

Put them all into a folder so you can enjoy the step bellow:

The script also creates a __init__.py file, so you can import them all at once:

from yourapp.models import *

Get the script here

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs