code: def create_code(user, client, scope, nonce, is_authentication,
                  code_challenge=None, code_challenge_method=None):
      
      code = Code()
      code.user = user
      code.client = client
  
      code.code = uuid.uuid4().hex
  
      if code_challenge and code_challenge_method:
          code.code_challenge = code_challenge
          code.code_challenge_method = code_challenge_method
  
      code.expires_at = timezone.now() + timedelta(
          seconds=settings.get('OIDC_CODE_EXPIRE'))
      code.scope = scope
      code.nonce = nonce
      code.is_authentication = is_authentication
  
      return code
docs: Create and populate a Code object.
      Return a Code object.