Django static configuration file and request acquaintance

A static configuration file

What is a static file:

  For the front end of the file has been written, we can directly take over, called a static file

  Example: bootstrap front-end frame has been written for a class of

    Pictures, css, js

 

Static file was placed on static default folder

static default folder by default subfolders created folder 
            css folder of the current site all the style file 
            js file js file of the current site all 
            img files in the current site all the picture files 
            to other (third-party front-end framework code plug-in code ...)

 

Static configuration file

= STATICFILES_DIRS [ 
   the os.path.join (base_dir, ' static ' ) 
 ] 
 as long as you enter the path static folder can access a specific file to

 

ps: configured as a list, you can add more than one file path, and move down to find

= STATIC_URL ' / static / '   # the name of the folder is not a static but rather an interface prefix 
    "" " as long as you want access to a resource file path to a static file must start with a static " "" 
    # manually static folder all exposed to the user resources 
    STATICFILES_DIRS = [ 
       os.path.join (base_dir, ' static ' ),   # real folder path 
        os.path.join (base_dir, ' static1 ' ),   # real folder path 
        os.path.join (base_dir, ' static2 ' ),   # the real folder path 
        os.path.join (base_dir, ' static3 ')  #The real folder path 
    ]

 

 Static file interface prefix dynamic analysis:

% Load% static { }
 <Link the rel = " this stylesheet " the href = " {% static 'on Bootstrap-3.3.7-dist / CSS / bootstrap.min.css'}% " > 
<Script the src = " {% static' on Bootstrap dist--3.3.7 / JS / bootstrap.min.js'}% " > </ Script> 
    using parser dynamically obtaining interface prefix

 

Two, request an initial method

  Method acquisition request request.method

Processing of the data is not just only wsgiref django backend module also done a lot of data processing 
        GET 
            request.GET data acquisition front-end get submitted (it is like a big dictionary) 
            values 
                request.GET.get ( ' username ' )   # Although the default value is a list, but just take a list of the last element 
                # strongly recommended that you use the form values in brackets 
                
                # if you want directly to list all out (******) 
                request.GET.getlist ( ' Hobby ' ) 
        POST 
            request.POST data acquisition front-end post submission (it is like a big dictionary) 
            values 
                request.POST.get ( ' username ' )   # Although the default value is a list, but just take a list of the last element 
                #Strongly recommended that you use the form values in brackets 
                
                # if you want directly to list all out (******) 
                request.POST.getlist ( ' Hobby ' )

 

Guess you like

Origin www.cnblogs.com/xiaowangba9494/p/11530011.html