1. Create a Auto_cmdb Python project and create a APP01 under Auto_cmdb
2. Connect to MySQL
Configuring in Seeting
DATABASES = {
' Default ': {
' ENGINE ': ' Django.db.backends.mysql ',
' NAME ': ' Auto_cmdb ',
' USER ': ' Root ',
' PASSWORD ': ' 123456 ',
' HOST ': ' 10.10.20.134 ',
' PORT ': '
}
}
3.models.py Establishing a table structure
Using Python manage.py Migrate
Error:importerror:no module named Rest_framework
Processing: Pip Install Djangorestframework
Error:importerror:no module named Daterange_filter
Processing: Pip Install Django-daterange-filter
Error: Importerror:no module named Import_export
Processing: Pip Install Django-import-export
[email protected] auto_cmdb]# python manage.py migrate
System Check identified some issues:
WARNINGS:
App01. Apiauth.users: (Fields. W340) NULL has a and no effect on Manytomanyfield.
App01. Asset.cabinet_order: (Fields. W122) ' Max_length ' is ignored when used with Integerfield
Hint:remove ' max_length ' from field
App01. Maintainence.maintain_type: (Fields. W122) ' Max_length ' is ignored when used with Integerfield
Hint:remove ' max_length ' from field
App01. Nic.ipaddr: (Fields. W900) Ipaddressfield has been deprecated. Support for it (except in historical migrations) would be a removed in Django 1.9.
Hint:use Genericipaddressfield instead.
App01. Server.software: (Fields. W340) NULL has a and no effect on Manytomanyfield.
App01. Software.types: (Fields. W122) ' Max_length ' is ignored when used with Integerfield
Hint:remove ' max_length ' from field
Operations to perform:
Synchronize unmigrated apps:django_filters, Staticfiles, messages, Daterange_filter, Import_export, rest_framework
Apply all Migrations:admin, ContentTypes, APP01, Auth, Sessions
Synchronizing Apps without migrations:
Creating tables ...
Running Deferred SQL ...
Installing Custom SQL ...
Running Migrations:
Rendering model states ... Done
Applying contenttypes.0001_initial ... Ok
Applying auth.0001_initial ... Ok
Applying admin.0001_initial ... Ok
Applying app01.0001_initial ... Ok
Applying app01.0002_auto_20141110_0740 ... Ok
Applying app01.0003_auto_20141110_0754 ... Ok
Applying app01.0004_auto_20141117_0848 ... Ok
Applying app01.0005_auto_20141118_0917 ... Ok
Applying App01.0006_server_software ... Ok
Applying app01.0007_auto_20141119_0741 ... Ok
Applying app01.0008_auto_20141120_0137 ... Ok
Applying app01.0009_auto_20141120_0317 ... Ok
Applying app01.0010_auto_20141120_0556 ... Ok
Applying app01.0011_auto_20141120_0725 ... Ok
Applying app01.0012_auto_20141120_0916 ... Ok
Applying APP01.0013_CPU_PARENT_SN ... Ok
Applying app01.0014_auto_20141121_0625 ... Ok
Applying app01.0015_auto_20141121_0627 ... Ok
Applying app01.0016_auto_20141124_0240 ... Ok
Applying app01.0017_auto_20141124_0333 ... Ok
Applying app01.0018_auto_20141124_0520 ... Ok
Applying app01.0019_auto_20141124_0820 ... Ok
Applying App01.0020_asset_hostname ... Ok
Applying app01.0021_auto_20141124_1116 ... Ok
Applying app01.0022_auto_20141125_0927 ... Ok
Applying app01.0023_auto_20141125_1126 ... Ok
Applying app01.0024_auto_20141126_0150 ... Ok
Applying app01.0025_auto_20141126_0154 ... Ok
Applying app01.0026_auto_20141126_0502 ... Ok
Applying app01.0027_auto_20141126_0516 ... Ok
Applying app01.0028_auto_20141126_0924 ... Ok
Applying app01.0029_auto_20141201_2033 ... Ok
Applying App01.0030_eventlog ... Ok
Applying app01.0031_server_manufactory ... Ok
Applying App01.0032_eventlog_create_at ... Ok
Applying App01.0033_server_model ... Ok
Applying app01.0034_auto_20141203_1450 ... Ok
Applying APP01.0035_REMOVE_ASSET_SN ... Ok
Applying app01.0036_auto_20141203_1651 ... Ok
Applying app01.0037_auto_20141204_0857 ... Ok
Applying app01.0038_auto_20141204_0901 ... Ok
Applying app01.0039_auto_20141204_1524 ... Ok
Applying app01.0040_auto_20141204_1833 ... Ok
Applying app01.0041_auto_20141204_1935 ... Ok
Applying app01.0042_auto_20141204_2315 ... Ok
Applying App01.0043_asset_asset_op ... Ok
Applying app01.0044_auto_20141205_2004 ... Ok
Applying app01.0045_auto_20141205_2241 ... Ok
Applying app01.0046_auto_20141205_2249 ... Ok
Applying app01.0047_auto_20141219_0908 ... Ok
Applying Contenttypes.0002_remove_content_type_name ... Ok
Applying auth.0002_alter_permission_name_max_length ... Ok
Applying auth.0003_alter_user_email_max_length ... Ok
Applying auth.0004_alter_user_username_opts ... Ok
Applying Auth.0005_alter_user_last_login_null ... Ok
Applying auth.0006_require_contenttypes_0002 ... Ok
Applying sessions.0001_initial ... Ok
Done!
This article is from the "write-free" blog, please be sure to keep this source http://fangniu.blog.51cto.com/8773628/1744278
AUTO_CMDB--01 's models.py Building table