程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

Django reverse generate models

編輯:Python

This instruction should be used by testers ,inspectdb, But the point is , I may not just link to a database , Database needs to be specified .

python manage.py inspectdb --database [settings Database configured in key] > models Specific path

in addition ,django Automatically generated comments , It's also very important

# This is an auto-generated Django model module.
# You'll have to do the following manually to clean this up:
# * Rearrange models' order
# * Make sure each model has one field with primary_key=True
# * Make sure each ForeignKey and OneToOneField has `on_delete` set to the desired behavior
# * Remove `managed = False` lines if you wish to allow Django to create, modify, and delete the table
# Feel free to rename the models, but don't rename db_table values or field names.

Summarized below :

  • Self pair models Sort , because python My own mechanism , Classes written below , The above class is unusable
  • Foreign keys and one-to-one associations , You have to build it yourself
  • managed=False Identify these models No django Migration created
  • Need to check every model Primary key of ,django There is no guarantee that the primary key will be created correctly

  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved