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 8418805
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T02:25:44+00:00 2026-06-10T02:25:44+00:00

I am new at web2py and i am struggling with it I am trying

  • 0

I am new at web2py and i am struggling with it

I am trying to crate a registration and login stuff. In models I have the following code where I create tabel for new users

usersdb = DAL('postgres://postgres:postgres@localhost/'+ request.vars['school'], migrate=True)
auth = Auth(usersdb, hmac_key=Auth.get_or_create_key())
usersdb.define_table(
    'users',
    Field('first_name', length=128, default=''),
    Field('last_name', length=128, default=''),
    Field('email', length=128, default='', unique=True),
    Field('address', length=256, default=''),
    Field('postcode', length=128, default=''),
    Field('city', length=128, default=''),
    Field('password', 'password', length=512, readable=False, label='Password'),
    Field('registration_key', length=512, writable=False, readable=False, default=''),
    Field('reset_password_key', length=512, writable=False, readable=False, default=''),
    Field('registration_id', length=512, writable=False, readable=False, default=''),
    format='%(first_name)s %(last_name)s')

So now in controler I have the following code:

usersdb = DAL('postgres://postgres:postgres@localhost/'+ request.vars['school'], migrate=True)
auth = Auth(usersdb, hmac_key=Auth.get_or_create_key())
auth.settings.registration_requires_approval = True
form = SQLFORM(usersdb.users)
if form.process(session=None, formname='test').accepted:
    response.flash = 'form accepted'
elif form.errors:
    response.flash = 'form has errors'
else:
    response.flash = 'please fill the form'
 # Note: no form instance is passed to the view

 #set sample validator (do not allow empty nor duplicate names)
return dict(form=form,config=config)  

The error is loged at SQLFORM (usersdb.users).
‘users’

I don’t know how actually this stuff works (connecting database to controler). I am hacking a code written by smb. else.

Thank you for any advice or short explanation.

Bye

  • 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-10T02:25:45+00:00Added an answer on June 10, 2026 at 2:25 am

    You should not repeat the definition of userdb or auth in the controller. Model files are executed on every request (except for conditional model files), and the controller is executed in an environment that contains any objects defined in the models. In your controller, you are overwriting the original userdb object with a fresh one, and you are defining auth again but not re-creating the “users” table — hence there is no longer a “users” table on userdb.

    Just remove the userdb and auth definitions from the controller.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an existing web2py application. Now I need to create a new registration
I have the following code in web2py/python: {{for row in db(db.t_problems.id==db.t_problems(request.args(0))).select(): }} Which grabs
While reading the web2py manual, I came across this following: 'Once a new user
New programmer here, I am trying to understand and break down this code below
I'm new to Python and I'm trying to install web2py in a virtualenv. I'm
New to Haskell and have a stumbling block. I'm trying to filter a list
New to Web2py, so my question might not be too clear. I'm trying to
New to Android and OpenCV. Been trying to to implement code from new book,
I have the following function defined in emacs - (defun web2py-server () (interactive) (shell-command
New to PHP and MySQL, have heard amazing things about this website from Leo

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.