python - Error when calling the metaclass bases -
finding difficult wrap around basic problem. i'm using python 2.7.10 follow flask tutorial being delivered using python 3.4. i'm aware of differences between 2 versions, seems knowledge isn't enough overcome situation. have amateur level experience in python. have feeling got class definition, unable nail it. , yes went through solutions similar error wasn't able relate solution problem.
traceback (most recent call last): file "manage.py", line 5, in <module> flask_init import app file "/users/sapp/desktop/ude/flask_init/__init__.py", line 12, in <module> author import views file "/users/sapp/desktop/ude/flask_init/author/views.py", line 3, in <module> form import registerform file "/users/sapp/desktop/ude/flask_init/author/form.py", line 5, in <module> class registerform(form): typeerror: error when calling metaclass bases module.__init__() takes @ 2 arguments (3 given)
my directory structure:
├── __init__.py ├── __init__.pyc ├── author │ ├── __init__.py │ ├── __init__.pyc │ ├── form.py │ ├── form.pyc │ ├── models.py │ ├── models.pyc │ ├── views.py │ └── views.pyc ├── blog │ ├── __init__.py │ ├── __init__.pyc │ ├── views.py │ └── views.pyc ├── manage.py ├── requirements.txt ├── settings.py ├── settings.pyc ├── templates │ ├── author │ └── base.html └── venv ├── bin ├── include ├── lib └── pip-selfcheck.json
manage.py:
import os, sys flask_script import manager, server flask_init import app manager = manager(app) manager.add_command("runserver", server( )) if __name__ == "__main__": manager.run()
form.py:
from flask_wtf import form wtforms import validators, stringfield, passwordfield wtforms.fields.html5 import emailfield class registerform(form): pass
init.py:
from flask import flask flask.ext.sqlalchemy import sqlalchemy app = flask(__name__) app.config.from_object('settings') db = sqlalchemy(app) import blog.views author import views
views.py:
from flask_init import app flask import render_template, redirect form import registerform @app.route('/register', method=('get', 'post')) def register(): form = registerform() return render_template('author/register.html', form=form)
i chose not tag wtforms i'm more concerned i'm missing when comes metaclasses between 2.7 , 3.4.
this has nothing python versions.
you're importing wrong thing in form.py; have form
instead of form
. former module, latter class, should inheriting from.
Comments
Post a Comment