将var名称传递为“字符串”

时间:2019-11-13 08:24:53

标签: python

是否可以通过“ GENDER”将其附加到QuestionFocus,然后获取QuestionFocus.GENDER后面的内容?我当然可以只通过QuestionFocus.GENDER,但这会使它比(可能)必要的时间更长。

def get_answers(question_focus):
    return Answer.objects.filter(
        response_id__in=get_super_guests().values_list("id", flat=True),
        question__focus=QuestionFocus.question_focus,
    ).order_by("-created")

context["genders"] = get_answers("GENDER")

0 个答案:

没有答案