title: Flask registration error: missing 1 positional argument
body: <p>I am still stuck with my registration form in Flask.
  I keep getting the following error msg:</p>
  
  <pre><code>TypeError: regUser() missing 1 required positional argument: 'rank'
  
  
  a@a.com $2a$12$7DG.DR3v3KC6QR6JCa4c4uwH.aONn1yR8vhLEfaGZ6iIihILbvKFW 000000
  127.0.0.1 - - [22/Sep/2015 18:49:30] "POST /register HTTP/1.1" 500 -
  Traceback (most recent call last):
    File "/home/alex/Python/pjctbluebook/lib/python3.4/site-packages/flask/app.py", line 1836, in __call__
      return self.wsgi_app(environ, start_response)
    File "/home/alex/Python/pjctbluebook/lib/python3.4/site-packages/flask/app.py", line 1820, in wsgi_app
      response = self.make_response(self.handle_exception(e))
    File "/home/alex/Python/pjctbluebook/lib/python3.4/site-packages/flask/app.py", line 1403, in handle_exception
      reraise(exc_type, exc_value, tb)
    File "/home/alex/Python/pjctbluebook/lib/python3.4/site-packages/flask/_compat.py", line 33, in reraise
      raise value
    File "/home/alex/Python/pjctbluebook/lib/python3.4/site-packages/flask/app.py", line 1817, in wsgi_app
      response = self.full_dispatch_request()
    File "/home/alex/Python/pjctbluebook/lib/python3.4/site-packages/flask/app.py", line 1477, in full_dispatch_request
      rv = self.handle_user_exception(e)
    File "/home/alex/Python/pjctbluebook/lib/python3.4/site-packages/flask/app.py", line 1381, in handle_user_exception
      reraise(exc_type, exc_value, tb)
    File "/home/alex/Python/pjctbluebook/lib/python3.4/site-packages/flask/_compat.py", line 33, in reraise
      raise value
    File "/home/alex/Python/pjctbluebook/lib/python3.4/site-packages/flask/app.py", line 1475, in full_dispatch_request
      rv = self.dispatch_request()
    File "/home/alex/Python/pjctbluebook/lib/python3.4/site-packages/flask/app.py", line 1461, in dispatch_request
      return self.view_functions[rule.endpoint](**req.view_args)
    File "/home/alex/Python/pjctbluebook/pjctBB/views.py", line 52, in register
      User.regUser("aaaa", "aaaa", "aaaaa", "000000")
  TypeError: regUser() missing 1 required positional argument: 'rank'
  </code></pre>
  
  <p>In my views, I have the following (hardcoding "rank" in this case)</p>
  
  <pre><code>@app.route('/register', methods=['GET', 'POST'])
  def register():
      if request.method == 'GET':
          return render_template('index.html')
  
      elif request.method == 'POST':
  
          email = request.form['email']
          username = request.form['username']
          password = generate_password_hash(request.form['pass1'])
          rank = 50
  
          print(email, password, username)
          User.regUser(email, password, username, rank)
  
      #    db.session.add(User(email, username, password, "50"))
      #    db.session.commit()
          return render_template('index.html')
  </code></pre>
  
  <p>The class User is imported into Views but only at the end of Views (as it was creating a circular reference and clashing with my "from pjctBB import app")</p>
  
  <pre><code>from pjctBB.models import User
  </code></pre>
  
  <p>In my models I have:</p>
  
  <pre><code>from pjctBB.views import db
  
  
  class User(db.Model):
  
      __tablename__ = "users"
  
      id = db.Column(db.Integer, primary_key=True)
      email = db.Column(db.String, nullable=False)
      username = db.Column(db.String, nullable=False)
      password = db.Column(db.String, nullable=False)
      rank = db.Column(db.Integer, nullable=False)
  
      def __init__(self, email, username, password, rank):
          self.email = email
          self.username = username
          self.password = password
          self.rank = rank
  
      def regUser(self, email, username, password, rank):
  
          db.session.add(User(email, username, password, rank))
          db.session.commit()
  </code></pre>
  
  <p>I tried to hardcode "rank", pass the value through a hidden field in the form itself etcetc and it doesnt work.
  when I removed any referebce about rank in both Views and Models, I still get the same error but now for variable "password"...</p>
  
  <p>Please note that when I print the values of email/username/password and rank in the console <strong>before</strong> trying to pass them to the function: they show accurately in the console.</p>
  
  <p>I am at a loss here. 
  I hope someone can see through the problem and give me some guidance.</p>
  
  <p>Thanks for reading me and I hope to read from you!</p>