简体   繁体   中英

In the Django project,how to rebuild the model classes by migrations file?

In the Django project, if the model folder files are deleted, is it possible to use the migrations folder files to rebuild the model classes?

@mohammadKazemSamiel- I tried the following with my Postgres Database.

python manage.py inspectdb > models.py

This will look at the Database configured in settings.py and based on the SQLschema will spit out the model in models.py. Though you might need to edit few fields once the models are generated.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM