django ninth day summary

# ## day22 
- 1 . Assets Change Record
 - 2 backstage management.
 --3 traditional way of business lines CRUD.
 --4 provide a CRUD components. 

# ## Recap: 
- 1 .cmdb 
     - Architecture:
         - asset acquisition portion Client 
         - API Django djangorestframework 
         - manage
        
 - 2 technical point 
     --1 . development closed principle
         - the source code of
         - configuration open
        
         - compatible with various patterns and scalable
             - Agent the subprocess 
             - SSH paramiko
             - Salt / ansible
         -Information acquisition hardware pluggable design
             - the importlib import module
             - the reflector
                
     2 - constrained class.
         - + inheritance   thrown
         - + abstract class abstract method
        
     --3 . Error Information
         - traceback.format_exc ()
        
     -. 4 . Uniquely identified 
         - hostname
        
     -. 5 .requests reQuest
        
     - 6 thread pool.
         - from concurrent.futures Import the ThreadPoolExecutor
        
     -. 7 .api check
         - Key | timestamp the MD5
         - Key | timestamp time 
         - Key only once
         - determining the time
        
    - 8.数据加密
        - rsa   
        
    - 9.api     
        - CBV djangorestframework
        - from rest_framework.views import APIView
        - from rest_framework.response import Response
    
###准备知识
```python
    class  Base():
        def f1():
            print('Base f1')
            self.f2()
            
        def f2():
            print('Base f2')

    
    class  Foo(Base):
        
        def f2():
            print('Foo f2')

    c1 = Foo()
    c1.f1()
```
    
```python
    Class Base()
        def f1():
            print('Base f1')
        

    Class Foo(Base)
        def f1():
            super().f1()
            print('Foo f1')
    
    
    c1 = Foo()
    c1.f1()
```    

```python    
    class Base():
        defF1 ():
             Print ( ' Base F1 ' ) 
        

    class Foo (Base):
         DEF F1 (): 
            Super () F1 (). 
            Print ( ' Foo F1 ' ) 
    
    class Bar (Base):
         DEF F1 (): 
            Super () .f1 () 
            Print ( ' Bar F1 ' ) 
            
    class D (Foo, Bar):
         Pass 
        
    D = D () 
    d.f1 () 
`` `
    
 - Super looking after the current class class method in accordance with the order of succession 
    
# ## display: 
--1 ordinary field
     -obj.filed
    
 - 2.choice ((. 1, ' M ' ),)
     - obj.filed _>. 1 
    - obj.get_ field name _display () M
    
 --3 foreign key. 
     -. _ foreign key field obj> Associate For    __str__ 
    - obj .name foreign key fields.
    
 -. 4 custom methods.
     - display-many 
     - plus css style 
    
    `` `Python 
    from django.utils.safestring Import mark_safe
     DEF show_s (self):
         return mark_safe ( ' <span : "Red Color"> xxxxxx </ span> style = ' ) 
    `` ` 
    

# step ## using stark components: 
--1. Django copy stark components to the project and registration
     - Registration:
      - ' stark.apps.StarkConfig '
     
- 2 create stark.py file in the app already registered.
 --3 use stark component routing. 
`` `Python 
    from django. conf.urls Import URL, the include 

    from stark.service.stark Import Site 
    the urlpatterns = [ 
        URL (R & lt ' ^ Stark / ' , the include (site.urls)) 
    ] 
`` `
 -. 4 . in stark.py file and write the configuration register 
`` Python ` 
    from stark.service.stark Import Site, StarkConfig
     fromRepository Import Models 


    class BusinessUnitConfig (StarkConfig):
         # display fields 
        list_display = [ ' ID ' , ' name ' ]
         # fuzzy search 
        search_list = [ ' name ' ]
         # sort 
        ORDER_BY = [ ' name ' , ' -id ' ] 


    site.register (models.BusinessUnit, BusinessUnitConfig) 
`` `        

 

Guess you like

Origin www.cnblogs.com/lilyxiaoyy/p/11567521.html