Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #This snippet here is the bit of code that enables my submit page to add a new user to my database
- def __init__(self, first, last, username, dob, password):
- self.first = first
- self.last = last
- self.username = username
- self.dob = dob
- self.password = password
- #This is my db model that is handling my database communication
- class User(db.Model):
- __tablename__ = 'tbl_user'
- can_create = False
- id = db.Column('user_id', db.Integer, primary_key=True)
- first = db.Column('user_first', db.String(15), nullable=False)
- last = db.Column('user_last', db.String(25), nullable=False)
- username = db.Column('user_username', db.String(80), unique=True, nullable=False)
- dob = db.Column('user_dob', db.DateTime, nullable=False)
- password = db.Column('user_password', db.String(80), nullable=False)
- admin = db.Column('user_admin', db.Boolean, default=False, nullable=False)
- #This is the code for my submit page and the form that is submitted on user account creation
- <form action="" class="form-signin" method="POST">
- <label for="inputFirst" class="sr-only">First Name</label>
- <input type="name" value="{{request.form.inputFirst}}" name="inputFirst" id="inputFirst" class="form-control" placeholder="First Name" required autofocus>
- <label for="inputLast" class="sr-only">Last Name</label>
- <input type="name" value="{{request.form.inputLast}}" name="inputLast" id="inputLast" class="form-control" placeholder="Last Name" required autofocus>
- <label for="inputEmail" class="sr-only">Email address</label>
- <input type="email" value="{{request.form.inputEmail}}" name="inputEmail" id="inputEmail" class="form-control" placeholder="Email address" required autofocus>
- <label for="dob" class="sr-only">Date of Birth</label>
- <input type="date" value="{{request.form.dob}}" name="dob" id="dob" class="form-control" required autofocus>
- <label for="inputPassword" class="sr-only">Password</label>
- <input type="password" value="{{request.form.inputPassword}}" name="inputPassword" id="inputPassword" class="form-control" placeholder="Password" required>
- <button id="btnSignUp" class="btn btn-lg btn-primary btn-block" type="submit">Sign up</button>
- <a href="{{url_for('login')}}">Already have an account? Log In Here!</a>
- </form>
- #when i have the def __init__ defined i can add the users with the submit page but i cannot modify them within the flask-admin console
- #alternatively when i do not have that i can modify the users with the flask-admin console but not add with submit.
- #when i have the __init__ defined i get this error
- TypeError
- TypeError: __init__() takes exactly 6 arguments (1 given)
- Traceback (most recent call last):
- File "/home/ubuntu/myproject/myprojectenv/lib/python2.7/site-packages/flask/app.py", line 1985, in wsgi_app
- response = self.handle_exception(e)
- File "/home/ubuntu/myproject/myprojectenv/lib/python2.7/site-packages/flask/app.py", line 1540, in handle_exception
- reraise(exc_type, exc_value, tb)
- File "/home/ubuntu/myproject/myprojectenv/lib/python2.7/site-packages/flask/app.py", line 1982, in wsgi_app
- response = self.full_dispatch_request()
- File "/home/ubuntu/myproject/myprojectenv/lib/python2.7/site-packages/flask/app.py", line 1614, in full_dispatch_request
- rv = self.handle_user_exception(e)
- File "/home/ubuntu/myproject/myprojectenv/lib/python2.7/site-packages/flask/app.py", line 1517, in handle_user_exception
- reraise(exc_type, exc_value, tb)
- File "/home/ubuntu/myproject/myprojectenv/lib/python2.7/site-packages/flask/app.py", line 1612, in full_dispatch_request
- rv = self.dispatch_request()
- File "/home/ubuntu/myproject/myprojectenv/lib/python2.7/site-packages/flask/app.py", line 1598, in dispatch_request
- return self.view_functions[rule.endpoint](**req.view_args)
- File "/home/ubuntu/myproject/myprojectenv/lib/python2.7/site-packages/flask_admin/base.py", line 69, in inner
- return self._run_view(f, *args, **kwargs)
- File "/home/ubuntu/myproject/myprojectenv/lib/python2.7/site-packages/flask_admin/base.py", line 368, in _run_view
- return fn(self, *args, **kwargs)
- File "/home/ubuntu/myproject/myprojectenv/lib/python2.7/site-packages/flask_admin/model/base.py", line 1997, in create_view
- model = self.create_model(form)
- File "/home/ubuntu/myproject/myprojectenv/lib/python2.7/site-packages/flask_admin/contrib/sqla/view.py", line 1077, in create_model
- if not self.handle_view_exception(ex):
- File "/home/ubuntu/myproject/myprojectenv/lib/python2.7/site-packages/flask_admin/contrib/sqla/view.py", line 1060, in handle_view_exception
- return super(ModelView, self).handle_view_exception(exc)
- File "/home/ubuntu/myproject/myprojectenv/lib/python2.7/site-packages/flask_admin/contrib/sqla/view.py", line 1071, in create_model
- model = self.model()
- TypeError: __init__() takes exactly 6 arguments (1 given)
- I have been working on this for hours and cannot find the solution. google has listed several and i have tried all of them to no avail. at this point im at a loss for what to do and would appreciate any help in getting me pointed in the right direction. Thanks
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement