day-75CRM

Q query

    1.直接用Q去查
    
    2.    from app01 import models
        models.Book.objects.filter(title__contains='',price__contains=2)
        <QuerySet []>
        from django.db.models import Q
        models.Book.objects.filter(Q(title__contains='')|Q(price__contains=2))
        <QuerySet [<Book: 三国演义>]>
        models.Book.objects.filter(Q(title__contains='')|Q(price__contains=8))
        <QuerySet [<Book: Gold Bottle>, <Book: Three Kingdoms>]> 
        Q = Q () 
        q.children.append (( ' title__contains ' , ' three ' ))   # Add query 
        q.children.append (( ' price__contains ' ,. 8 )) 
        models.Book.objects.filter (Q)
         <QuerySet that [<Book: Three Kingdoms>]> 
        q.connector = ' or '                            # Q is the default objects and relationships may be modified by a connector into or relationship 
        models.Book.objects.filter (Q)
         <QuerySet that [<Book: gold bottle>, <Book: Three Kingdoms>]>

 

Get Variable model table names corresponding foreign key field
  models.Book._meta.get_field ( 'publish'). Rel.to

pop

  

the window.open (URL, '' , ' width = 800px ' ) 
        
        sub-pages can be called the parent page Method 
            window.opener.fatherFunc (...) 
            the window.close ()
        
         . 1 . What are needed with a plus tab 
            form_obj.field 
                form_obj.is_pop = True 
            plus debugging styles
        
         2 . plus bind to the click event 
            url add url foreign key field corresponding to the model table 
            app_label = models.Book._meta.app_label 
            MODEL_NAME = models.Book._meta.model_name 
            URL = Reverse ( ' %% S_ADD S_ ' %(app_label, MODEL_NAME)) 
        
        
            function WindowOpen (URL) { 
                the window.open (URL, '' , ' width = 800px, 400px height = ' ) 
            }
            
         2 . How to distinguish the logical addition or the rear end surface of the sub-page is transmitted page post request 
            later url open subpage plus get request parameter 
            acquiring tag id values form_obj rendering 
            form_obj.auto_id
            
            
        
         . 3 . Add the parent page adding data 
            function the addOption = document.createElement ( ' Option ' )

 

  

Guess you like

Origin www.cnblogs.com/klw1/p/11312178.html
75