The Django Admin background app operation for CMDB

Source: Internet
Author: User

Django's backend functionality is very useful:

First you need to register the app to the background

Cat asset/apps.pyfrom __future__ Import unicode_literalsfrom django.apps import Appconfigclass assetconfig (AppConfig): Name = ' Asset ' verbose_name = ' environment list ' # Background display names cat asset/admin.pyfrom django.contrib import Adminfrom Asset.model S import Asset_pro, asset_test, redis_pro# Register your models here.admin.site.register ([Asset_pro, Asset_test, Redis_ Pro])

After landing, found the Operation object times wrong: get () returned more than one topic-it returned 2!
  

650) this.width=650; "Src=" Http://s5.51cto.com/wyfs02/M00/86/B6/wKiom1fIFJbCNNfUAAA-_j9blUM233.png-wh_500x0-wm_3 -wmp_4-s_2711285364.png "title=" 23.png "alt=" Wkiom1fifjbcnnfuaaa-_j9blum233.png-wh_50 "/>

So it needs to be defined in models:

Class asset_test (models. Model):     nodes = models. Charfield (max_length=20, verbose_name=u ' Application node ')     applications = models. Charfield (max_length=30, verbose_name=u ' Application name ',  primary_key=true)   #后台app默认更改对象      ipaddr = models. Charfield (max_length=20, verbose_name=u ' IP address ')    #需定义primary_key, otherwise the ID column is automatically created      mobile = models. Charfield (max_length=20, verbose_name= ' mobile ')     dms = models. Charfield (max_length=5, verbose_name= ' DMS ')     flag = models. Charfield (max_length=5, verbose_name= ' flag ')     def __unicode__ (self):         return u "%s"  % (SELF.IPADDR)     class  Meta:        db_table =  ' fcenv_test '    #表名, Default to App name + class name &Nbsp;       verbose_name = u ' Testing Environment Service information '          verbose_name_plural = u ' test environment Asset Management '

The principle is that a column of data must be primary_key, and then the day after tomorrow to manipulate the data is normal.

650) this.width=650; "Src=" Http://s3.51cto.com/wyfs02/M02/86/B6/wKioL1fIFOGSscpVAAAMTHifn-A733.png-wh_500x0-wm_3 -wmp_4-s_2074229931.png "title=" Sdf.png "alt=" Wkiol1fifogsscpvaaamthifn-a733.png-wh_50 "/>


Background modification data, front-end real-time display.

This article is from the creator think blog, so be sure to keep this source http://strongit.blog.51cto.com/10020534/1845338

The Django Admin background app operation for CMDB

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.