码迷,mamicode.com
首页 > 数据库 > 详细

auto_cmdb--01之models.py建表

时间:2016-02-23 16:03:21      阅读:995      评论:0      收藏:0      [点我收藏+]

标签:python   cmdb   

1.创建一个auto_cmdb的python项目,在auto_cmdb下创建一个app01

2.连接mysql

 在seeting中配置


    DATABASES = {

        ‘default‘: {

            ‘ENGINE‘: ‘django.db.backends.mysql‘,

            ‘NAME‘:‘auto_cmdb‘, 

    ‘USER‘: ‘root‘,

    ‘PASSWORD‘: ‘123456‘,

    ‘HOST‘: ‘10.10.20.134‘,

    ‘PORT‘: ‘‘

        }

    }

3.models.py建立表结构

 使用python manage.py migrate


 报错:ImportError: No module named rest_framework

 处理:pip install djangorestframework

 报错:ImportError: No module named daterange_filter

 处理:pip install django-daterange-filter

 报错:ImportError: No module named import_export

 处理:pip install django-import-export


 

[root@jy-xxxx auto_cmdb]# python manage.py migrate

System check identified some issues:


WARNINGS:

app01.ApiAuth.users: (fields.W340) null has 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) will be removed in Django 1.9.

HINT: Use GenericIPAddressField instead.

app01.Server.software: (fields.W340) null has 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

 大功告成!

本文出自 “随便写写” 博客,请务必保留此出处http://fangniu.blog.51cto.com/8773628/1744278

auto_cmdb--01之models.py建表

标签:python   cmdb   

原文地址:http://fangniu.blog.51cto.com/8773628/1744278

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!