Tag: Django CBV View

[django 2.2] Get/Post를 동일한 템플릿에 표시하기.

Django class based view를 이용하여 동일한 페이지에 GET 과 POST를 모두 표시하는 방법. 1. View 작성(app/views.py) class GetPostView(View): template_name = ‘getpost.html’ data = [ {‘name’: ‘fox’, ‘title’: ‘test1’, ‘is_published’: True }, {‘name’: ‘wolf’, ‘title’: ‘test 2’, ‘is_published’: False}, {‘name’: ‘cat’, ‘title’: ‘life of cat’, ‘is_published’: True}, ] def get(self, request, *argc, **kwargs): context = { …

Continue reading