Python Learning---drawer frame analysis [likes function/File upload analysis]0317

Source: Internet
Author: User

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 ' >


<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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.