[Fixed]-Gender as a model from a SQL statement in django 1.8

1👍

Run this command to auto-generate models from an already existing database. But first make sure you’ve properly linked database to django app .

python manage.py inspectdb > models.py

Do check models.py file and make some changes if you something isn’t rendered correctly.

For inspectdb approach, read this: https://docs.djangoproject.com/en/1.8/howto/legacy-databases/

Alternatively, you can write all the models by yourself and set managed = False. No database table creation of deletion will be executed by Django on this model. But it is somewhat complicated and puts some limits on model relationships.

For managed=False approach, read this: https://docs.djangoproject.com/en/1.8/ref/models/options/#managed

Leave a comment