Django - Xadmin in function

app_label

Features

If you do not models.py standard which defines model, you must specify which app belong to this model.

use

app_label = 'oms'

 

actions

Features

Action plug-in data list page provides data selection, data selection can be done through Action special treatment provided by default Action for the bulk delete function.

Screenshot

 

use


DoOrdinary_0 class (views.Action):
the verbose_name = 'batch to normal'

def do_action(self, queryset):
request = self.request
for obj in queryset:
obj.status = 0
obj.save()

self.msg ( 'disposed success', 'success')

DoOrdinary_1 class (views.Action):
verbose_name = 'Deleted batch is set to'
DEF do_action (Self, QuerySet):
Request = self.request
for obj in QuerySet:
obj.status = 1
obj.save ()

self.msg ( 'disposed success', 'Success')
Actions = (DoOrdinary_0, DoOrdinary_1)


add_redirect_url

Features

Screenshot

use

add_redirect_url = '/xadmin/page/vtalktags/?vtalk_id=%s&_redirect=/xadmin/meila/vtalk/'

 

exclude

Features

Hidden field when adding

Screenshot

 

use

exclude = ('create_time', 'slug')

 

fields

Features

Adding fields when displayed

Screenshot

 

use

fields = ('title', 'cat')

 

form

Features

Defined functions limits on the number of functions in the forms.py

Screenshot

 

use

form = TopListForm

 

form_layout

Features

When you add a layout of the list

Screenshot

 

use

from xadmin.layout import Main, TabHolder, Tab, Fieldset, Row, col, AppendedText, Side, Field

form_layout = (

    Fieldset(u'',

                   Row('cat', 'tag'),

                   Row('title', 'status')

                   Row('display_order),

                   css_class = 'unsort no_title'

                   ),

    )

 

fieldsets

Features

Screenshot

use

 

fk_url_param

Features

Screenshot

use

fk_url_param = { 'user':{'_p_user_vest': '1'}}

 

hidden_menu

Features

Screenshot

use

list_display

Features

The display list

Screenshot

 

use

list_display = ('id', 'title', 'img_tz', 'cat', 'tag', 'status', 'create_time')

 

list_filter

Features

filter

Screenshot

 

use

list_filter = ('cat', 'status', 'create_time')


list_per_page

Features

Limit the number of displayed per page

Screenshot

 

use

list_per_page = 5 # per page 5

 

list_editable

Features

The plug-in can instantly edit a page in the list of values ​​in a field, the use of Ajax technology, no need to submit or refresh the page to complete the modification data for fields that require frequent changes: quite useful (such as status).

Screenshot

 

use

list_editable = ['status', 'display_order']

 

list_distplay_links

Features

Screenshot

use

list_display_links = ('title',)

 

menu_group

Features

Display belongs menu

Screenshot

 

use

menu_group = 'vtalk_group'

 

menu_index

Features

Screenshot

use

menu_index = 4

 

model_icon

Features

Screenshot

use

model_icon = 'fa fa-twitter'

 

order

Features

Position in the current menu

Screenshot

 

use

order = 2

 

ordering

Features

Sequence

use

ordering = [ '-id',] # DESC

ordering = [ 'id',] # ascending

 

raw_id_fields

Features

Screenshot

use

 

readonly_fields 

Features

Set read-only field

Screenshot

use

readonly_fields = ['img_width', 'img_height']

 

relfield_style

Features

Screenshot

use

relfield_style = 'fk-ajax'

 

remove_permissions 

Features

Screenshot

use

remove_permissions = ('delete', 'add', 'update')

 

serach_fields

Features

Search Content

Screenshot

 

use

search_fields = ('nickname', 'slug')

 

style_fields

Features

Screenshot

use

style_fields = {

                        'user': 'fk_raw'

                         }

 

show_detail_fields

Features

For more information related fields can be displayed in list page

Screenshot

 

use

show_detail_fields = ('id',)

 

use_related_menu

Features

Screenshot

use

use_related_menu = False

 

search_sphinx_ins

Features

Screenshot

use

 

verbose_name

Features

show name

Screenshot

 

use

verbose = 'sticker'
---------------------
Author: __ yuan__
Source: CSDN
Original: https: //blog.csdn.net/lyysr/article/details/ 48735053
copyright: This article is a blogger original article, reproduced, please attach Bowen link!

Guess you like

Origin www.cnblogs.com/mashuqi/p/11022487.html