Use the Python Django framework and jQuery to implement the AJAX shopping cart page

Source: Internet
Author: User
This article mainly introduces how to use the Python Django framework and jQuery to implement the AJAX shopping cart page. for example, if you need RESTfulAPI in JSON format built in Django, refer Integrate jquery in Django
First, static resources are usually put in the static folder:

static/  css/    djquery.css    samples/      hello.css  js/    jquery-1.7.1.min.js    samples/      hello.js

Css and js both divide folders according to the application name (samples here). if there are many files, you can drag the molecular folder.

Django usually uses a template to display html, and we usually use an inherited template, so we need to share elements, such as global css, for jquery. the introduction of js is written to the base template, and the elements of the specific page are put into the specific template. This involves the issue of nesting. See the following example:
Base.html

   
   
   {% Block title %} title {% endblock %}  
 {% Block styles %}
 {% Endblock %}   

{% Block content %} content {% endblock %}

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: info-contact@alibabacloud.com 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.