code: def get_field_name(self):
          
          if hasattr(self, 'agnocomplete_field') and \
             hasattr(self.agnocomplete_field, 'to_field_name'):
              return self.agnocomplete_field.to_field_name or 'pk'
          return 'pk'
docs: Return the model field name to be used as a value, or 'pk' if unset