Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

models.py not getting generated when using the inspectdb

Tags:

python

django

I am trying to generate models.py from a legacy database using the inspectdb command. Everything was fine, i see the table names being inspected and corresonding classes made in the console, after that operation is completed, I checked the directory where the manage.py is residing, and there was no models.py generated.

Can anyone throw some light on this?

Thanks, John

like image 891
logeeks Avatar asked Apr 30 '26 23:04

logeeks


1 Answers

The inspectdb command does not automatically create a models.py file, by default it outputs the models to the console.

You can save the output to a file on Unix systems with

$ python manage.py inspectdb > models.py

Note this will overwrite models.py if it already exists!

like image 69
Alasdair Avatar answered May 03 '26 13:05

Alasdair