Hie , i am a new developer from Zimbabwe and the logic i used for my add to cart is giving me an error how can i handle this?
MODEL CODE: db.define_table('products', Field('product_name'), Field('current_price', 'float'), Field('image', 'upload'), Field('description', type='text'), Field('product_availability', requires = IS_IN_SET(['Available','Not Available'])), auth.signature, ) db.define_table('orders', Field('productId', db.product), Field('userId', db.auth_user), Field('qty'), Field('order_date'), ) CONTROLLER CODE def proc(): prodDict = {} productrows = db(db.products).select() for x in productrows: prodDict[x.id] = x.product_name order_date = str(request.now.year) + "-" + str(request.now.month) + "-" + str(request.now.day) qty = request.vars.qty productId = request.vars.productId userId = session.auth.user.id sql = "INSERT INTO orders (productId, userId, qty, order_date) values (str(productId), str(userId), str(qty), str(order_date))" #sql = sql + "(" + str(productId) + "," + str(userId) + "," + str(qty) + "," + str(order_date) + "')" r = db.executesql(sql) rows = db(db.orders.userId==session.auth.user.id).select(orderby=~db.orders.id) return locals() VIEWCODE {{extend 'layout.html'}} <h1>Shopping Cart</h1> <p> Items in Cart </p> <table class='table table-striped table-hover'> {{for x in rows:}} <tr> <td>{{x.qty}}</td> <td>{{=prodDict[x.id]}}</td> <td><a href='#delete'>Delete</a></td> </tr> {{pass}} </table> <br/> <a href='view'>Continue Ordering</a> PLEASE ASSIST .....the add to cart button is there on my main page but when i add something to cart it gives me a error below Traceback 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. Traceback (most recent call last): File "C:\Users\elisha.bere\Downloads\my_python_files\PIZZZA PROJECT\web2py_win\web2py\gluon\restricted.py", line 219, in restricted exec(ccode, environment) File "C:/Users/elisha.bere/Downloads/my_python_files/PIZZZA PROJECT/web2py_win/web2py/applications/project/controllers/products.py" <http://127.0.0.1:8000/admin/default/edit/project/controllers/products.py>, line 58, in <module> File "C:\Users\elisha.bere\Downloads\my_python_files\PIZZZA PROJECT\web2py_win\web2py\gluon\globals.py", line 419, in <lambda> self._caller = lambda f: f() File "C:/Users/elisha.bere/Downloads/my_python_files/PIZZZA PROJECT/web2py_win/web2py/applications/project/controllers/products.py" <http://127.0.0.1:8000/admin/default/edit/project/controllers/products.py>, line 50, in proc r = db.executesql(sql) File "C:\Users\elisha.bere\Downloads\my_python_files\PIZZZA PROJECT\web2py_win\web2py\gluon\packages\dal\pydal\base.py", line 768, in executesql adapter.execute(query) File "C:\Users\elisha.bere\Downloads\my_python_files\PIZZZA PROJECT\web2py_win\web2py\gluon\packages\dal\pydal\adapters\__init__.py", line 67, in wrap return f(*args, **kwargs) File "C:\Users\elisha.bere\Downloads\my_python_files\PIZZZA PROJECT\web2py_win\web2py\gluon\packages\dal\pydal\adapters\base.py", line 412, in execute rv = self.cursor.execute(command, *args[1:], **kwargs) OperationalError: no such column: productId Error snapshot [image: help] <http://127.0.0.1:8000/admin/default/ticket/project/127.0.0.1.2018-06-04.16-26-14.cccf8530-dc40-4060-b792-ebd9a3b014e2#> <class 'sqlite3.OperationalError'>(no such column: productId) -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.