Odevzdávátko: initial data pro formset
This commit is contained in:
parent
0fa14b08b5
commit
b91e639089
1 changed files with 10 additions and 3 deletions
|
@ -2,7 +2,7 @@ from django.views.generic import ListView, DetailView, FormView
|
|||
from django.views.generic.list import MultipleObjectTemplateResponseMixin,MultipleObjectMixin
|
||||
from django.views.generic.base import View
|
||||
from django.views.generic.detail import SingleObjectMixin
|
||||
from django.shortcuts import redirect
|
||||
from django.shortcuts import redirect, get_object_or_404
|
||||
from django.urls import reverse
|
||||
|
||||
from dataclasses import dataclass
|
||||
|
@ -135,8 +135,15 @@ class DetailReseniView(DetailView):
|
|||
template_name = 'seminar/odevzdavatko/detail.html'
|
||||
|
||||
def aktualni_hodnoceni(self):
|
||||
...
|
||||
return []
|
||||
reseni = get_object_or_404(m.Reseni, id=self.kwargs['pk'])
|
||||
result = [] # Slovníky s klíči problem, body, cislo_body -- initial data pro f.OhodnoceniReseniFormSet
|
||||
for hodn in m.Hodnoceni.objects.filter(reseni=reseni):
|
||||
result.append(
|
||||
{"problem": hodn.problem,
|
||||
"body": hodn.body,
|
||||
"cislo_body": hodn.cislo_body,
|
||||
})
|
||||
return result
|
||||
|
||||
def get_context_data(self, **kw):
|
||||
ctx = super().get_context_data(**kw)
|
||||
|
|
Loading…
Reference in a new issue