1

I am learning Django and i need to know whether i can link a table already present in the database to a model (since, i heard that tables are created by Django for whatever models we are creating inside django app ).

If so, how can it be done?

sportymsk
  • 43
  • 1
  • 8

1 Answers1

7

inspectdb works fine now. (Django 1.7+) Simply running manage.py inspectdb will create classes for all tables in database and display on console.

 $ python manage.py inspectdb

Save this as a file by using standard Unix output redirection:

 $ python manage.py inspectdb > models.py

Read further from here.

Prakhar Trivedi
  • 8,218
  • 3
  • 28
  • 35