Created
October 27, 2017 13:00
-
-
Save nck2/4b2b5aea3989556962978d3e6290d79d to your computer and use it in GitHub Desktop.
타임에러
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# model.py | |
created_at=models.DateTimeField(auto_now_add=True,verbose_name="접수일시",help_text="접수일시입니다.") | |
# 제대로 나오는 view | |
def selform_detail(request,pk): | |
post=get_object_or_404(Tselection,pk=pk) | |
return render(request,'tsel/selection_detail.html',{'post':post}) | |
# selection_detail.html - 제대로 나오는 템플릿 : 정확한 시간인 오후 2시 26분이 찍힙니다. | |
<li>접수일시: {{post.created_at|date:"Y /m /d P" }}</li> | |
# 아래는 위의 내용을 엑셀로 다운받는 작업입니다. 이때 위의 정확한 시간이 오후2시 26분이라면 | |
# 아래 작업으로 다운받아지는 엑셀에는 새벽 5시 26분으로 정확하게 9시간이 빠르게 찍힙니다. | |
# 에러가 나오는 view | |
def tsel_xlwriter(request): | |
from openpyxl import load_workbook | |
from openpyxl.writer.excel import save_virtual_workbook | |
import os | |
from django.conf import settings | |
wb=load_workbook(os.path.join(settings.BASE_DIR,'tsel','form.xlsx')) | |
ws=wb.active | |
post=Tselection.objects.all() | |
postnum=post.count() | |
for rn, row in enumerate(range(2, 2+postnum)): | |
ws.cell(column=2, row=row, value=post[rn].created_at) # 여기 명령에서 오류 새벽 5시 26분로 찍힘 | |
print(post[rn].created_at) # 찍어봐도 새벽 5시 26분입니다. | |
print(post[rn].created_at) | |
#settings.py | |
LANGUAGE_CODE = 'en-us' | |
TIME_ZONE = 'Asia/Seoul' | |
USE_I18N = True | |
USE_L10N = True | |
USE_TZ = True |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment