но, он показывает ошибку ""GET /static/css/stylesheet.css HTTP/1.1" 404 1813 file Oder "
models.py
class ChapterQuestions(models.Model):
question_id = CharField(primary_key=True, max_length=40)
question_order = CharField(max_length=40, blank=True, null=True)
question_wording = CharField(max_length=4000, blank=True, null=True)
question_type = CharField(max_length=1, blank=True, null=True)
sub_question = CharField(max_length=1, blank=True, null=True, default='N')
sub_question_trigger = CharField(max_length=1, blank=True, null=True, default='Y')
answer_required = CharField(max_length=1, blank=True, null=True, default='Y')
parent_question = models.ForeignKey('self', on_delete=models.DO_NOTHING)
chapter = models.ForeignKey(ReportChapter, on_delete=models.DO_NOTHING)
update_date = models.DateField(blank=True, null=True)
update_user = models.ForeignKey(User, on_delete=models.DO_NOTHING, db_column="update_user", blank=True, null=True)
class Meta:
managed = True
db_table = "Chapter_Question"
views.py
class LfrReportChapterOneView(PermissionRequiredMixin, TemplateView):
permission_required = "RockHub_App.is_in_risk_and_ic_team"
template_name = "../templates/dashboards/lfr/lfr_report_chapitre1_create.html"
def get_context_data(self, *args, **kwargs):
context = super(LfrReportChapterOneView, self).get_context_data(*args, **kwargs)
data = ChapterQuestions.objects.filter(chapter_id=1).order_by("question_id")
context["questions"] = data
return context
Во время отладки я вижу все данные, доступные в базе данных, но в HTML файле, когда я пишу
<h1>{{ questions.question_id }}</h1>
или
<div hidden>
{% for qst in questions %}
{{ qst.question_id }},{{ qst.question_name }}
{% endfor %}</div>
<div><h1>{{ qst.question_id }}</h1></div>
Ничего не отображается!!!
попробуйте это
def get_context_data(self, **kwargs):
context = super(LfrReportChapterOneView, self).get_context_data(**kwargs)
context["questions"] = ChapterQuestions.objects.filter(chapter_id=1).order_by("question_id")
return context