我正在写将自定义值传递给内联 css,但我无法得到这个,因为我对 django 框架非常陌生。
提前致谢
<div class="progress-bar bg-success" role="progressbar" style="width: {{news_curr_idx}}" aria-valuenow="25" arwiria-valuemin="0" aria-valuemax="100">{{news_curr_idx}}</div>
</div>
视图.py
@login_required
def tutorial(request):
start = datetime.datetime.now()
news_curr_idx = request.user.profile.news_curr_idx
if news_curr_idx == TOTAL_QUESTION:
return redirect('end_experiment')
assigned_chunk_to_user(request.user.profile)
news_curr = NewsItem.objects.all().filter(
chunk_id=request.user.profile.assigned_chunk_idx)[news_curr_idx]
context = {
'newsItem': news_curr,
'news_curr_idx': news_curr_idx + 1,
'total_question': TOTAL_QUESTION
}
if request.method == 'POST':
end = datetime.datetime.now()
elapsed_time = end - start
user_annot_form = TutorialAnnotationForm(request.POST, newsItem=news_curr, author=request.user.profile,
elapsed_time=elapsed_time.microseconds)
if request.POST.get("action_name") == 'ISSUE':
assert not UserAnnotation.objects.filter(
author=request.user.profile).filter(newsItem=news_curr).values()
return redirect('report_issue')
if user_annot_form.is_valid():
if request.POST.get("action_name") == 'NEXT':
user_annot_form.save()
request.user.profile.news_curr_idx += 1
request.user.profile.save()
assert UserAnnotation.objects.filter(
author=request.user.profile).filter(newsItem=news_curr).values() return redirect('tutorial') else: # TODO add logger print(user_annot_form.errors.as_json())
return render(request, 'annotating/tutorial.html', context)