남기면 좋잖아

7. 장고 Forms(2) 본문

Programming/Django

7. 장고 Forms(2)

Beautiful Hugo 2020. 7. 17. 19:53
반응형

DRF-React Study

Chapter 5. 장고 Forms

Messages Framework

  • Messages Framework

    • 현재 User를 위한 1회성 메세지
    • HttpRequest 인스턴스를 통해 메시지를 남김
      • View 에서만 사용 가능
    • JS로도 사용가능
  • 레벨

    • DEBUG
    • INFO
    • SUCCESS
    • WARNING
    • ERROR
  • 출력 tags 변경하기

    settings.py

    from django.contrib.messages import constants
    
    MESSAGE_TAGS = {
      constants.DEBUG: 'secondary',
      constants.ERROR: 'danger',
    }
  • Messages 소모하기

    layout.html

    {% if messages %}
      {% for message in messages %}
        <div class="alert alert-{{ message.tags }}">
          {{ message.message }}
        </div>
      {% endfor %}
    {% endif %}

built-in CBV를 통한 Form 처리

  • Built-in CBV API
    • FormView, CreateView, UpdateView, DeleteView
반응형

'Programming > Django' 카테고리의 다른 글

9. 비SPA 방식으로 인스타그램 St 만들기  (0) 2020.07.19
8. 장고 기본 인증 구현  (0) 2020.07.17
7. 장고 Forms  (0) 2020.07.16
6. 웹 프론트엔드 기초 및 장고 static  (0) 2020.07.16
5. 장고 Views(2)  (0) 2020.06.29
Comments