title: "AttributeError: 'function' object has no attribute 'get'" in SQLAlchemy ORM Object contructor - Flask
body: <p><strong>EDIT</strong> <em>Found my error! Leaving problem description as is, but appending answer bellow.</em></p>
  <p>In my registration function, I want to create a new User object.
  I've defined a User Table like this:</p>
  <pre><code>class User(_USERDB.Model, UserMixin):
      &quot;&quot;&quot;
      User defining Data
      &quot;&quot;&quot;
      __tablename__ = &quot;users&quot;
      __table_args__ = {'extend_existing': True}
      id = Column(Integer, primary_key=True)
      mail = Column(Text, unique=True, nullable=False)
      pw = Column(Text, nullable=False)
      date_of_creation = Column(DateTime(timezone=True), default=datetime.now)  # the date the user is created
      settings = relationship(&quot;UserSettingProfile&quot;, back_populates=&quot;user&quot;, passive_deletes=True)
      admin = Column(Boolean, default=False, nullable=False)
      world_id = Column(Integer, nullable=True)
  
      def __dict__(self):
          return {
              &quot;id&quot;: self.id,
              &quot;mail&quot;: self.mail,
              &quot;date_of_creation&quot;: self.date_of_creation,
              &quot;admin&quot;: self.admin,
              &quot;world_id&quot;: self.world_id
          }
  
  </code></pre>
  <p>If I now use the constructor as in other tutorials (TechWithTim - Flask Bog tutorial)</p>
  <p><code>new_user = User(mail=mail, pw=pw_hash, admin=admin)</code></p>
  <p>I get the error from the Title
  <code>&quot;AttributeError: 'function' object has no attribute 'get'&quot;</code></p>
  <p>I've already tried stepping through the debugger to spot where this comes from, but it's not much more helpful than the stack trace. All I did was validate that the stack trace, is the stack trace (not very helpful indeed)</p>
  <pre><code>Traceback (most recent call last):
    File &quot;E:\project\venv\Lib\site-packages\flask\app.py&quot;, line 2091, in __call__
      return self.wsgi_app(environ, start_response)
    File &quot;E:\project\venv\Lib\site-packages\flask\app.py&quot;, line 2076, in wsgi_app
      response = self.handle_exception(e)
    File &quot;E:\project\venv\Lib\site-packages\flask\app.py&quot;, line 2073, in wsgi_app
      response = self.full_dispatch_request()
    File &quot;E:\project\venv\Lib\site-packages\flask\app.py&quot;, line 1518, in full_dispatch_request
      rv = self.handle_user_exception(e)
    File &quot;E:\project\venv\Lib\site-packages\flask\app.py&quot;, line 1516, in full_dispatch_request
      rv = self.dispatch_request()
    File &quot;E:\project\venv\Lib\site-packages\flask\app.py&quot;, line 1502, in dispatch_request
      return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)
    File &quot;E:\project\web_interface\routes\api_routing.py&quot;, line 135, in register
      new_user = User(mail=mail, pw=pw_hash, admin=admin)
    File &quot;&lt;string&gt;&quot;, line 4, in __init__
      
    File &quot;E:\project\venv\Lib\site-packages\sqlalchemy\orm\state.py&quot;, line 479, in _initialize_instance
      with util.safe_reraise():
    File &quot;E:\project\venv\Lib\site-packages\sqlalchemy\util\langhelpers.py&quot;, line 70, in __exit__
      compat.raise_(
    File &quot;E:\project\venv\Lib\site-packages\sqlalchemy\util\compat.py&quot;, line 207, in raise_
      raise exception
    File &quot;E:\project\venv\Lib\site-packages\sqlalchemy\orm\state.py&quot;, line 477, in _initialize_instance
      return manager.original_init(*mixed[1:], **kwargs)
    File &quot;E:\project\venv\Lib\site-packages\sqlalchemy\orm\decl_base.py&quot;, line 1157, in _declarative_constructor
      setattr(self, k, kwargs[k])
    File &quot;E:\project\venv\Lib\site-packages\sqlalchemy\orm\attributes.py&quot;, line 459, in __set__
      self.impl.set(
    File &quot;E:\project\venv\Lib\site-packages\sqlalchemy\orm\attributes.py&quot;, line 1094, in set
      old = dict_.get(self.key, NO_VALUE)
  AttributeError: 'function' object has no attribute 'get'
  </code></pre>
  <p>For completion's sake, here is my api_routing.py file:</p>
  <pre><code>from flask import Blueprint, request, jsonify
  from database import User, UserSettingProfile
  
  @api_routes.route(&quot;/register&quot;, methods=[&quot;POST&quot;])
  def register():
  
      response = {&quot;message&quot;: &quot;&quot;}
  
      try:
          mail = request.values[&quot;mail&quot;]
          pw1 = request.values[&quot;pw1&quot;]
          pw2 = request.values[&quot;pw2&quot;]
  
      except KeyError as e:
          response[&quot;message&quot;] = f&quot;{e=} | Missing argument. Expected: mail, password1, password2&quot;
          return jsonify(response), 400
  
      admin = False
  
      pw_hash = hash_pw(pw1)
      print(f&quot;{pw_hash=}\n{mail=}\n{admin=}&quot;)
      new_user = User(mail=mail, pw=pw_hash, admin=admin)
      print(new_user)
      new_user_settings = UserSettingProfile(user_id=new_user.id)
  
      _USERDB.session.add(new_user)
      _USERDB.session.add(new_user_settings)
      _USERDB.session.commit()
  
      login_user(new_user, remember=True)
      response[&quot;message&quot;] = f&quot;{mail=} registered and logged in successfully&quot;
      return jsonify(response), 200
  
  </code></pre>
  <p>All the parameters that I pass on into the User() constructor are valid and as expected:</p>
  <pre><code>pw_hash='$2b$14$6UpznQzJgw/zLZLGmjBkfOpm.D8iGXf/OsfqRkAVyzcZFM88kdos2'
  mail='test_mail'
  admin=False
  </code></pre>
  <p>After looking at other posts, I double-checked:
  The name &quot;User&quot; in the namespace indeed maps to the model-class I defined.</p>