Thanks :) that worked. A new problem emerged though so I'll post that one in a new thread. Thanks again.
On Monday, 10 December 2012 15:27:12 UTC, Niphlod wrote: > > I think that the problem is this: > db.comment.content_id.default = db.content.id > > You can't set a default value that is a Field (as db.sometable.somefield). > Seeing the code it may be a bug: you probably meant > db.comment.content_id.default = content.id <http://db.content.id> > Can you try to remove that and see if it works ? > > On Monday, December 10, 2012 10:59:10 AM UTC+1, sasogeek wrote: >> >> I stumbled upon this error while trying to submit a form in my app. >> here's the code related to the database table "content" >> >> ############################### >> # # # # # # # Model # # # # # # >> ############################### >> >> db.define_table('content', >> Field('title', unique=True), >> Field('file', 'upload'), >> Field('description','text'), >> Field('time', 'datetime', update=request.now), >> Field('message', 'text'), >> format = '%(title)s',) >> >> db.define_table('comment', >> Field('content_id', 'reference content'), >> Field('author'), >> Field('body', 'text')) >> >> >> ############################## >> # # # # # # Controller # # # # # # >> ############################## >> def show(): >> content = db.content(request.args(0)) or redirect(URL('index')) >> db.comment.content_id.default = db.content.id >> form = crud.create(db.comment, >> next=URL(args=content.id)) >> form.custom.widget.author = auth.user.first_name +' '+ >> auth.user.last_name >> comments = db(db.comment.content_id==db.content.id).select() >> return dict(content=content, comments=comments, form=form) >> >> >> When I submit the form, i get a ticket with the error in the title of >> this post. and the traceback shows the following... >> >> Traceback (most recent call last): >> File "/usr/lib/pymodules/python2.7/gluon/restricted.py", line 204, in >> restricted >> exec ccode in environment >> File "/home/sasogeek/web2py/applications/images/controllers/default.py" >> <http://127.0.0.1:8000/admin/default/edit/images/controllers/default.py>, >> line 82, in <module> >> File "/usr/lib/pymodules/python2.7/gluon/globals.py", line 172, in <lambda> >> self._caller = lambda f: f() >> File "/usr/lib/pymodules/python2.7/gluon/tools.py", line 2533, in f >> return action(*a, **b) >> File "/usr/lib/pymodules/python2.7/gluon/tools.py", line 2533, in f >> return action(*a, **b) >> File "/usr/lib/pymodules/python2.7/gluon/tools.py", line 2533, in f >> return action(*a, **b) >> File "/usr/lib/pymodules/python2.7/gluon/tools.py", line 2533, in f >> return action(*a, **b) >> File "/home/sasogeek/web2py/applications/images/controllers/default.py" >> <http://127.0.0.1:8000/admin/default/edit/images/controllers/default.py>, >> line 31, in show >> next=URL('show', args=content.id)) >> File "/usr/lib/pymodules/python2.7/gluon/tools.py", line 3126, in create >> formname=formname, >> File "/usr/lib/pymodules/python2.7/gluon/tools.py", line 3069, in update >> detect_record_change = self.settings.detect_record_change): >> File "/usr/lib/pymodules/python2.7/gluon/sqlhtml.py", line 1267, in accepts >> self.vars.id = self.table.insert(**fields) >> File "/usr/lib/pymodules/python2.7/gluon/dal.py", line 5597, in insert >> return self._db._adapter.insert(self,self._listify(fields)) >> File "/usr/lib/pymodules/python2.7/gluon/dal.py", line 914, in insert >> raise e >> OperationalError: no such column: content.id >> >> >> help... >> >> --

