python - use django create database scheme or use powerdesigner create database scheme -
i ready start new project django,and invloves operations database.i have 2 way scheme:
- use powerdesigner design database scheme , output sql,then use
python manage.py inspectdb
generate models. - design model use
python manage.py makemigrations
,python manage.py migrate
database scheme.
does explain 2 ways' difference , how should choose?
from inspectdb's documentation:
use if have legacy database you’d use django. script inspect database , create model each table within it.
its better if have working db , want use django on it. has limitations like:
- if inspectdb cannot map column’s type model field type, it’ll use textfield , insert python comment 'this field type guess.' next field in generated model.
- if database column name python reserved word (such 'pass', 'class' or 'for'), inspectdb append '_field' attribute name. example, if table has column 'for', generated model have field 'for_field', db_column attribute set 'for'. inspectdb insert python comment 'field renamed because python reserved word.' next field.
also shortcut method, not recommended if starting django project.
also writing models, running makemigration
, migrate
command create database scheme containing custom fields such :
auth_group auth_group_permissions auth_permission auth_user auth_user_groups auth_user_user_permissions
which essential django system if want use authentication backend, user model etc core parts of django.
Comments
Post a Comment