The Django Admin daemon registers the model and displays

Source: Internet
Author: User

Register the model in admin background and display the other fields:

To modify the admin.py under the app, register the model:

From. Models Import VM
Admin.site.register (VM) # registering a model named VM

The VM content is displayed in the admin background, but only the return field in model is displayed by default:

For example, to display the other fields in the model named HV, modify the admin.py as follows:

 from. ModelsImporthv,vmadmin.site.register (VM)classhvadmin (admin. Modeladmin):#Fields = [' sn ', ' IP ']FieldSets =[None, {' Fields': ['name']}), (None, {' Fields': ['IP']}),] List_display= ('name','IP')#add more columns.List_filter = ['IP']#add Filter function.Search_fields = ['name']#Add search function.Admin.site.register (hv,hvadmin)

The results are shown below:

The Django Admin daemon registers the model and displays

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.