열심히 썼는데 왜 날라갔느냐 😔 Retry..
from django.http import Http404
: 404 에러 처리 (1)
from django.shortcuts import get_object_or_404
: 404 에러 처리 (2)
from django.db.models import F
, selected_choice.votes = F('votes') + 1
,selected_choice.save()
: 여러 사용자의 서버에서 동시에 vote 값을 증가시킨다고 가정했을 때, 서버 메모리에서만 증가시키면 원하는 방향으로 갱신이 안될 수가 있다. 따라서 DB에서 증가시키는 방식으로 에러 방지
admin 페이지도 마음대로 꾸밀 수가 있다. from django.contrib import admin
호출하고, @admin.display(boolean=True, description='최근생성(하루기준)')
이런 식으로 데코레이션 작성도 가능