python - Multiple outputs from wtforms flask -


how multiple outputs printed on page 1 single wtform? have form created on forms.py

class postform(form):     content = stringfield("what's up?", validators=[datarequired()])     company_name = stringfield("company's name", validators=[datarequired()])     job_type = selectfield('job type', choices=[('fulltime', 'full time'), ('parttime', 'part time'), ('contract', 'contract'), ('internship', 'internship')])     country = selectfield(         'country', choices=[('bhr', 'bahrain'), ('kwt', 'kuwait'), ('om', 'oman'), ('qtr', 'qatar'), ('sa', 'saudi arabia'), ('uae', 'u.a.e')]     )     job_description = textareafield("job description", validators=[datarequired()])     responsibilities = textareafield("responsibilities future employee have/do.", validators=[datarequired()])     job_requierments = textareafield("requirements needed job.", validators=[datarequired()])     bonus = textareafield("bonus/extras employee can have makes him better candidate job.", validators=[datarequired()])     perks = textareafield("perks future employee can working you", validators=[datarequired()])     about_us = textareafield("abous (about employer/company)", validators=[datarequired()])     apply_now = textareafield("how apply", validators=[datarequired()])     email = stringfield('your email', validators=[datarequired(), email()])     mob_numb = stringfield('your phone number(s), , please use numbers!', validators=[datarequired()]) 

and in models.py got following (note doing following online course adding , editing own stuff why don't know how add multiple outputs 1 form)

class post(model):     timestamp = datetimefield(default=datetime.datetime.now)     user = foreignkeyfield(         rel_model=user,         related_name='posts'     )     content = textfield() 

and html file outputting form

{% extends "layout.html" %}  {% block content %}  {% post in stream %}   <h2><a href="{{ url_for('stream', username=post.user.content) }}"> {{ post.content }} </a></h2>    {% endfor %} {% endblock %}    

i content printed out correctly , works great, when try add example country_name = textfield() under content = textfield() in models error:

peewee.operationalerror: no such column: t1.company_name 

and if go html page , write

{{ form.country_name }} 

i following error

jinja2.exceptions.undefinederror: 'form' undefined 

and if use

post.country_name 

nothing shows.

any ideas?

edit: forgot add app.py form

    @app.route('/new_post', methods=('get', 'post')) @login_required def post():     form = forms.postform()     if form.validate_on_submit():         models.post.create(user=g.user.id,                            content=form.content.data.strip())         flash("message posted! thanks!", "success")         return redirect(url_for('index'))     return render_template('post.html', form=form) 

peewee.operationalerror: no such column: t1.company_name 

if add new field in models.py need update database table well. error indicating model (in models.py) not match table in database.

and if go html page , write

{{ form.country_name }} 

i following error

jinja2.exceptions.undefinederror: 'form' undefined

in view handeling request need specify form in return. otherwise won't able access form.

def page():    myform = forms.myform()    return render_template('page.html', form=myform) 

and if use

post.country_name 

nothing shows. ideas?

this hard tell since in html have pasted trying loop through "stream" not submitting along html in "post()" method have shown.

the code below give idea on how use form in webpage.

app.py

def page():    myform = myform()    return render_template('page.html', forminhtml=myform) 

page.html

content: {{ forminhtml.content }} company name: {{ forminhtml.company_name }} 

Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -