Is it possible to generate django models from the database?

前端 未结 3 1583
佛祖请我去吃肉
佛祖请我去吃肉 2020-11-28 03:51

I\'ve been messing around with Django and the Django ORM at home, and I\'ve got to say, I feel it is one of the best out there in terms of ease of use.

However, I wa

3条回答
  •  醉话见心
    2020-11-28 04:06

    (Django 1.7.1) Simply running python 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
    

    (This works for me with mysql and django 1.9)

提交回复
热议问题