2015-06-17

mysql log error

如果你的 mysql log 有以下訊息
Native table 'performance_schema'.'file_instances' has the wrong structure
Native table 'performance_schema'.'cond_instances' has the wrong structure
Native table 'performance_schema'.'rwlock_instances' has the wrong structure
Native table 'performance_schema'.'mutex_instances' has the wrong structure
...

原因是你的資料庫結構是舊的,而你用的mysql卻是新的

2015-06-05

django 樣版 列出所有 form error 的方法

django 樣版 列出所有 form error 的方法
{{form.non_field_errors}} ==> 列出 global error
{{ field.errors }} ==> 跟欄位有關的 error


方法一:
         {% if form.errors %}
          <div class="alert alert-error">
            <button type="button" class="close" data-dismiss="alert">×</button>
            {{form.non_field_errors}}
            {% for field in form %}
              {% if field.errors %}
                <li>{{ field.label }}: {{ field.errors }}</li>
              {% endif %}
            {% endfor %}
          </div>
        {% endif %}



方法二:
            {% for field, errors in form.errors.items %}
              {% for error in errors %}
                {{error}}
              {% endfor %}
            {% endfor %}
                     


註:只帶訊息不帶 <ul> <li> 方法
form.errors.backup_email.0 (加個.0 , 取 str)