Web2py新手求助:如何通过appadmin创建manager用户组
Solution for Creating "manager" Group in Web2py Appadmin
Hey there! I totally get how frustrating it is when you're following the docs and can't find the exact step you need—been there with Web2py's appadmin more times than I'd admit 😅 Let's break this down simply:
Step 1: Access the Auth Tables in Appadmin
Appadmin doesn't have a dedicated "group creation" UI, but you can directly interact with Web2py's built-in auth database tables:
- Open your app's appadmin interface (e.g.,
http://localhost:8000/your_app_name/appadmin) - Scroll down to the Database section, and select your app's database (usually
db.sqlitefor default setups) - Look for the
auth_grouptable in the list of tables—this is where all user groups are stored.
Step 2: Create the "manager" Group
- Click the insert link next to
auth_group - In the form that pops up:
- Fill the
rolefield withmanager(this is the group name the system will recognize) - Add an optional
description(like "Application admin group") to keep things organized
- Fill the
- Hit the submit button, and your manager group is now created!
Step 3: Add Users to the "manager" Group
- Go back to the database table list, find the
auth_membershiptable (this links users to groups) - Click insert here, then:
- Select the target user from the
user_iddropdown - Select your newly created
managergroup from thegroup_iddropdown
- Select the target user from the
- Submit the form, and that user is now part of the manager group.
Quick Alternative: Use Web2py Shell (Faster for Testing)
If you want a quicker way (great for debugging), you can use the Web2py shell:
- Open your terminal, navigate to your Web2py root folder
- Run this command to enter your app's shell:
python web2py.py -S your_app_name -M - Then run these lines to create the group and add a user (replace
USER_IDwith the actual user's ID):# Create manager group manager_group_id = db.auth_group.insert(role='manager', description='Application managers') # Add user to group (replace USER_ID with the user's id from auth_user table) db.auth_membership.insert(user_id=USER_ID, group_id=manager_group_id) # Commit the changes db.commit()
Bonus: Recommended Resources for Web2py Beginners
The official docs are solid, but here are some other great resources:
- The Web2py Cookbook has in-depth sections on authentication and group management that go beyond the overview
- Web2py's official community forum has tons of beginner-friendly threads where you can ask specific questions
- The official Web2py YouTube channel has short, practical tutorials that walk through auth setup step-by-step
内容的提问来源于stack exchange,提问作者Mubarak Awal
相关产品推荐
相关产品推荐

