【问题标题】:unable to insert new record using web2py sample application无法使用 web2py 示例应用程序插入新记录
【发布时间】:2016-05-05 07:56:35
【问题描述】:

我是 web2py 的新手,我创建了一个简单的应用程序,然后是 http://www.developerdrive.com/2012/09/python-and-web-building-dynamic-web-forms-in-web2py-from-ground-%E2%80%93-part-i/

使用这个我可以得到前端表单页面,我可以输入详细信息并提交这些并在appadmin页面db.registration表中检查那些未显示的,下面是我的代码

default.py 控制器:

def form_a():
form = SQLFORM(db.registration)
return dict(form=form)

db.py 模型:

db = DAL('sqlite://storage.sqlite')
db.define_table('registration',
Field('firstname', requires=IS_NOT_EMPTY()),
Field('lastname', requires=IS_NOT_EMPTY()),
Field('gender', requires=IS_IN_SET(['Male', 'Female'])),
Field('username', requires=IS_NOT_EMPTY()),
Field('password', 'password'),
Field('about_you', 'text'),
Field('image', 'upload'))

默认/form_a.html 视图:

<h5> User Registration Form </h5>
<br  />
{{=form}}
<br  />

【问题讨论】:

    标签: python sqlite web2py


    【解决方案1】:

    您必须处理要插入数据的表单:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-01-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-07-02
      相关资源
      最近更新 更多