M
M
Michael2014-05-27 11:39:52
MongoDB
Michael, 2014-05-27 11:39:52

How to submit form generated by wtforms based on mongoengine model?

Hello, there is a function that builds a form based on the mongoengine model

from flask_wtf import Form
from flask.ext.mongoengine.wtf import model_form
from models.modelfile import DataUser

def add_newuser_form():
    return model_form(DataUser)

there is a get function that gives the page, and what this function gives
def get(self):
        form = add_newuser_form()
        return render_template('admin/admin.html', form =form)

there is a pattern
{% block contentplace %}

                         {{ form.login }}
{% endblock %}

we get an error
File "D:admin_controller.py", line 13, in get
form = add_newuser_form()
File "D:\add_new_user.py", line 9, in add_newuser_form
add_form = model_form(DataUser)
File "C:\Python34\lib\site-packages\flask_mongoengine\wtf\orm.py", line 268, in model_form
field_dict = model_fields(model, only, exclude, field_args, converter)
File "C:\Python34\lib\site-packages\flask_mongoengine\wtf\orm.py", line 225, in model_fields
names = ((k, v.creation_counter) for k, v in model._fields.iteritems())
AttributeError: 'dict' object has no attribute 'iteritems'

why? and how to fix it?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Rostislav Grigoriev, 2014-05-27
@nextel

Because in third python dict doesn't have iteritems method .
python3porting.com/preparing.html#index-5

M
Michael, 2014-05-27
@nextel

As user @crazyzubr wrote "Edits on the third python, as I see it, have already been made . Only the version has not yet been released. In this case, you can install directly from the
git pip install -e git+ https://github.com/MongoEngine/flask- mongoengine.g... "

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question