Click to praise the function analysis
The front desk passes over news id[new_id] and session[session within the user ID and user information] to the backstage
In the background news database users and news is many-to-many relationships, to see the third table of the content, interpretation of the user ID corresponding to the information there is no new_id, if there is remove[cancel like], otherwise add a point like
obj = News.objects.get (new_id=id) b = obj.favor.filter (uid=request.session[' uid '). COUNT () If B: obj.remove ( request.session[' UID ']) Else: obj.add (request.session[' uid '))
File Upload function Analysis
File Upload function:
The input tag type= ' file ' has a onchange function to monitor and, if there is a change, triggers an AJAX request that sends the file to the server's specific path, returning the URL to the IFRAME.
There is upload time in the IFRAME, and the path is written to our database after clicking.
Settings for the Upload box:
General <a href= "" > also sets the transparency of input to 0
<input type= ' file ' enctype= ' Multipartform ' >
</a>
<form id= ' F1 ' > <iframe ></iframe> ... .. <input type= ' file ' onchange= ' Uploadimage (); "/> </form>function uploadimage () { document.getElementById (' F1 '). Submit ()}
Python Learning---drawer frame analysis [likes function/File upload analysis]0317