How to Design with CSS in Django form

Source: Internet
Author: User
This article mainly introduces how to use CSS in Django form design. Django is the most famous Python popular development framework, the quickest way to modify the display of a form is to use CSS. Especially the Error List, which can enhance the visual effect. The automatically generated Error List accurately uses''
    '', So that we can use CSS for them. The following CSS makes the error more eye-catching:

     
     

    Although it is convenient to automatically generate HTML, you may want to overwrite the default display in some cases. {Form. as_table} and other methods are quick methods during development. form display methods can also be easily rewritten in form.

    Each field component (,,Or similar), you can access {form. Field name} for separate rendering. </P>

      Contact us  Contact us  {% if form.errors %}    

    Please correct the error{{ form.errors|pluralize }} below.

    {% endif %}

    {Form. message. errors} Will

      If the field is valid or the form is not bound, an empty string is displayed. We can also treat form. message. errors as a Boolean value or perform iteration on the list. For example:

      {% if form.message.errors %}

        {% for error in form.message.errors %}
      • {{ error }}
      • {% endfor %}
      {% endif %} Message: {{ form.message }}

      If the verification fails, this Code adds an "errors" to the class attribute of p containing the error field and displays the error information in an ordered list.

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.