0

Is there a way to pass "GENDER" attach it to QuestionFocus and then get what's behind QuestionFocus.GENDER? I could of course just pass QuestionFocus.GENDER but it would make it longer than (maybe) necessary.

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")
Joey Coder
  • 3,199
  • 8
  • 28
  • 60
  • 1
    `QuestionFocus.GENDER` looks way better to me, because a good linter will detect if someone by mistake requests something that doesn't exist, like `get_answers('GENDR')` – bereal Nov 13 '19 at 08:32
  • Okay, yes that's a good argument. – Joey Coder Nov 13 '19 at 08:35

0 Answers0