Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9215099
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T02:07:34+00:00 2026-06-18T02:07:34+00:00

I am learning how to use sqlalchemy and I am developing small app. I

  • 0

I am learning how to use sqlalchemy and I am developing small app. I am having some issues trying to update data stored in the db using the ORM. I’m not sure what I am missing. The form edit_product.html gets populated with the right data however the return redirect(url_for statement is fired without updating the data. I am using merge(), I tried using add() as suggested by some tutorials, however if I do this I get an error saying that the record already exists.

This is my edit_product function in the views.py:

from database import db_session
@app.route('/product/edit/<int:product_id>', methods=['GET', 'POST'])
def edit_product(product_id):
    product = Product.query.filter(Product.id == product_id).first()
    form = NewOtrosForm(obj=product)
    if request.method == 'POST':
        print request.form
        if form.validate():
            form.populate_obj(product)
            db_session.commit()
        return redirect(url_for('product'))
    else:
        return render_template('edit_product.html', form=form)

This is what I have in my edit form in the jinja2 template:

{% from "_formhelpers.html" import render_field %}
    <form method=post action="">
        <dl>
            {{ render_field(form.name) }}
            {{ render_field(form.price) }}
            {{ render_field(form.description) }}
            {{ render_field(form.provider) }}
            {{ render_field(form.detalles) }}
        </dl>
        <p><input type="submit" value="Save Changes"></p>
    </form>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T02:07:35+00:00Added an answer on June 18, 2026 at 2:07 am

    Can you try to change the below from :

    form = NewOtrosForm(obj=product)
    

    to:

    form = NewOtrosForm(request.form, obj=product)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am learning to use GWT with App Engine in Eclipse. I included the
I'm learning to use raw sockets, and im trying to prase out the tcp
I'm learning to use the PHP interactive shell, but I'm having trouble with multi-line
I'm learning to use GWT 2.0 and I'm trying to convert the StockWatcher demo
I'm learning to use the write function and am trying to print only a
I'm learning the use of the switch statement and using the rand() and srand()
I'm learning to use F# to build WPF applications. I using this as reference.
I'm learning to use the fantastic enlive library to do some web-scraping. I need
I am learning to use mysql.So, I got some problems. I have three table
I'm trying to use SqlAlchemy to make Sqlite database tables inside of Pylons. I'm

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.