我可以将process.env.production
设置为true
还是将其转换为"true"
?
即。必须在Heroku中配置vars总是字符串,或者它们可以是布尔值吗?
另外:如果if/else
中的index.ejs
条件在process.env.production
上的true
条件被设置为def export_myreport(request, sd, ed):
from xlsxwriter.workbook import Workbook
import cStringIO as StringIO
from django.utils.encoding import smart_str
# create a workbook in memory
output = StringIO.StringIO()
wb = Workbook(output)
bg = wb.add_format({'bg_color': '#9CB640', 'font_color': 'black'})
bg2 = wb.add_format({'bg_color': '#FFFFFF', 'font_color': 'black'})
ws = wb.add_worksheet('My Report')
row_num = 0
summary = MyModel.objects.filter(time__range = (sd, ed)).select_related()
row_num += 2
row = [
smart_str(u"Time"),
smart_str(u"Item"),
smart_str(u"User")
]
for col_num in xrange(len(row)):
ws.write(row_num, col_num, row[col_num], bg)
for s in summary:
row_num += 1
row2 = [
s.time,
s.model_name,
s.user.first_name
]
for col_num in xrange(len(row2)):
ws.write(row_num, col_num, row2[col_num], bg2)
wb.close()
output.seek(0)
response = HttpResponse(output.read(), content_type="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
response['Content-Disposition'] = "attachment; filename=myreport.xlsx"
return response
,那么在呈现之前是否会对其进行评估?
答案 0 :(得分:6)
所有heroku配置变量都是环境变量,在linux环境中,它们只能是字符串。
因此,您的应用中所有变量都将成为字符串 但是没有什么能阻止你做以下事情:
var is_production = process.env.production === 'true'