nodes: 0, module; 1, function_definition; 2, function_name:prepare_value; 3, parameters; 4, block; 5, identifier:self; 6, identifier:value; 7, expression_statement; 8, if_statement; 9, return_statement; 10, comment:"""
          To avoid evaluating the lazysorted callable more than necessary to
          establish a potential initial value for the field, we do it here.
  
          If there's
          - only one template choice, and
          - the field is required, and
          - there's no prior initial set (either by being bound or by being set
            higher up the stack
          then forcibly select the only "good" value as the default.
          """; 11, boolean_operator; 12, block; 13, call; 14, comparison_operator:value is None; 15, attribute; 16, expression_statement; 17, if_statement; 18, attribute; 19, argument_list; 20, identifier:value; 21, None; 22, identifier:self; 23, identifier:required; 24, assignment; 25, comparison_operator:len(choices) == 1; 26, block; 27, call; 28, identifier:prepare_value; 29, identifier:value; 30, identifier:choices; 31, call; 32, call; 33, integer:1; 34, expression_statement; 35, identifier:super; 36, argument_list; 37, identifier:list; 38, argument_list; 39, identifier:len; 40, argument_list; 41, assignment; 42, identifier:TemplateChoiceField; 43, identifier:self; 44, attribute; 45, identifier:choices; 46, identifier:value; 47, subscript; 48, identifier:self; 49, identifier:choices; 50, subscript; 51, integer:0; 52, identifier:choices; 53, integer:0
code: def prepare_value(self, value):
          """
          To avoid evaluating the lazysorted callable more than necessary to
          establish a potential initial value for the field, we do it here.
  
          If there's
          - only one template choice, and
          - the field is required, and
          - there's no prior initial set (either by being bound or by being set
            higher up the stack
          then forcibly select the only "good" value as the default.
          """
          if value is None and self.required:
              choices =list(self.choices)
              if len(choices) == 1:
                  value = choices[0][0]
          return super(TemplateChoiceField, self).prepare_value(value)