01. xadmin the form of a custom layout

xadmin form custom layout
- override get_form_layout ()
apps.courses.adminx.py
class NewCoursesAdmin(object):
  list_display = ['name', 'desc', ...]
  search_fields = ['name', 'desc', ... ]
  list_filter = ['name', 'teacher__name', 'desc', ... ]

  def get_form_layout(self):
    #self.org_obj means that, when it is modified only when the present set, new or old style 
    IF self.org_obj: 
      self.form_layout = ( 
        the Main ( 
                    The fieldset ( ' Lecturer information ' ,
                              ' Teacher ' , ' course_org ' ,
                              # no to the current named area 
                             css_class = ' Unsort no_title ' 
                             ), 
                    The fieldset ( ' basic information ' ,
                              ' name ', ' Desc ' ,
                              # of shorter field, available Row () so that they are displayed in a row 
                             Row ( ' learn_times ' , ' Degree ' ), 
                             Row ( ' category ' , ' Tag ' ),
                              ' youneed_know ' , ' teacher_tell ' , ' the Detail ' , 
                             ), 
                ), 
                # right sidebar
                Side ( 
                    The fieldset ( ' access information ' ,
                              # 'fav_nums', 'click_nums', 
                             ' Students. ' , ' ADD_TIME ' , 
                             ), 
                ), 
                Side ( 
                    The fieldset ( ' Select ' ,
                              ' is_banner ' , ' is_classics ' , 
                             ), 
                ) ,
            )
    #print (self .__ class __.__ mro__) can view the current mro order, look what a class 
    return Super (NewCoursesAdmin, Self) .get_form_layout ()

Guess you like

Origin www.cnblogs.com/jiangzongyou/p/12018297.html