【发布时间】:2019-02-01 09:55:04
【问题描述】:
我以数字的形式将用户的可用性保存在我的数据库中。 1 个用户可用,0 个用户不可用。例如,如果用户在周一早上和晚上有空,但白天不可用,在我的数据库中,我将有“101” 现在我想向我的用户展示他们的可用性。 我的想法是,对于每种情况,我都会创建并向他们展示不同的图像。 不幸的是,7天的可能性太多了。
我的问题是如何在我的模板中有效地显示这些数据?
我开始写我的观点,这里是:
if request.user.is_authenticated:
try:
name = coach.objects.get(user=request.user)
except coach.DoesNotExist:
name = coach(user=request.user)
objs = Lesson.objects.all().filter(mycoach = name)
args = {'objs': objs}
if name.monday=="111" and name.tuesday=="111" and name.wednesday=="111" and name.thursday=="111" and name.friday=="111" and name.saturday=="111" and name.sunday=="111" :
args['image_url'] = static('img/111111111111111111111.pdf')
if name.monday=="011" and name.tuesday=="111" and name.wednesday=="111" and name.thursday=="111" and name.friday=="111" and name.saturday=="111" and name.sunday=="111" :
args['image_url'] = static('img/011111111111111111111.pdf')
messages.add_message(request, messages.INFO, 'Welcome to your profile')
return render(request, 'Task.html', args)
else:
return render(request, 'home.html')
【问题讨论】:
标签: python css django django-templates