Want to use my existing mysql database with django

前端 未结 2 1849
执念已碎
执念已碎 2020-12-28 21:44

I have created a django project and now rendering templates. I have a mysql database already with loads of tables and data.

From what i saw in the tutorials, the mo

相关标签:
2条回答
  • 2020-12-28 22:07

    inspectdb works fine now. (Django 1.7.1) 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
    

    Reference

    0 讨论(0)
  • 2020-12-28 22:15

    There is an way by which Django will auto-magically create models based on tables using the inspectdb option of manage.py. A short guide is provided in Django Documentation itself on Integrating Django with a legacy database

    0 讨论(0)
提交回复
热议问题