Update your Django db model

By | May 12, 2023

If you have changed your database schema, you can up date your model by first running the inspectdb command.

python manage.py inspectdb > models.py

If you have too many tables in your database, pipe the results to a temporary file first and then manually copy the models over.

python manage.py inspectdb > models_temp.py

Then run:

python manage.py makemigrations

ref: https://dev.to/idrisrampurawala/creating-django-models-of-an-existing-db-288m

Leave a Reply

Your email address will not be published. Required fields are marked *