pythonweb2py

web2py: global name 'crud' is not defined


I am currently following a web2py tutorial and I am asked to append to my controls/default.py:

def entry_post():
"""returns a form where the can entry a post"""
form = crud.create(db.post)
return dict(form=form)

Which is fine but if I try to go to: mywebsite/app/default/entry_post I get a ticket error: global name 'crud' is not defined

Now, I've read the web2py documentation and I know that crud.create(db.table) is a valid syntax, so why does this happen?

Thanks for your answer


Solution

  • BTW. Crud is an old API which we no longer support.

    form = crud.create(db.post)
    

    should be rewritten as

    form = SQLFORM(db.post).process()