def index(): cmd = curso_facade.list_cursos_cmd() cursos = cmd() edit_path = router.to_path(edit) delete_path = router.to_path(delete) curso_form = curso_facade.curso_form() def localize_curso(curso): curso_dct = curso_form.fill_with_model(curso) curso_dct['edit_path'] = router.to_path(edit_path, curso_dct['id']) curso_dct['delete_path'] = router.to_path(delete_path, curso_dct['id']) return curso_dct localized_cursos = [localize_curso(curso) for curso in cursos] context = {'cursos': localized_cursos, 'new_path': router.to_path(new)} return TemplateResponse(context, 'cursos/curso_home.html')
def index(): cmd = curso_facade.list_cursos_cmd() curso_list = cmd() curso_form = curso_facade.curso_form() curso_dcts = [curso_form.fill_with_model(m) for m in curso_list] return JsonResponse(curso_dcts)