I got this Error, I am trying to create a simple web project using web.py. But unfortunately when I try to register a user I got the error. I tried so hard but I can't find any way to solve this. Would anyone please help to find out the solution to my problem? Error:
Traceback (most recent call last):
File "C:\Users\Fahim\AppData\Local\Programs\Python\Python38\lib\site-packages\web\application.py", line 280, in process
return self.handle()
File "C:\Users\Fahim\AppData\Local\Programs\Python\Python38\lib\site-packages\web\application.py", line 271, in handle
return self._delegate(fn, self.fvars, args)
File "C:\Users\Fahim\AppData\Local\Programs\Python\Python38\lib\site-packages\web\application.py", line 517, in _delegate
return handle_class(cls)
File "C:\Users\Fahim\AppData\Local\Programs\Python\Python38\lib\site-packages\web\application.py", line 495, in handle_class
return tocall(*args)
File "F:\Programs\Python\Python 3 Beginner to Advanced\10 Project 5 - Web Development Project Using Web.py\CodeWizard\Controller.py", line 30, in POST
reg_model.insert_user(data)
File "F:\Programs\Python\Python 3 Beginner to Advanced\10 Project 5 - Web Development Project Using Web.py\CodeWizard\Models\RegisterModel.py", line 15, in insert_user
id = self.Users.insert({"username": data.username, "name": data.name, "password": data.password, "email": data.email})
AttributeError: 'RegisterModel' object has no attribute 'Users'
127.0.0.1:13919 - - [28/Nov/2022 01:30:44] "HTTP/1.1 POST /postregistration" - 500 Internal Server Error
Register.html:
<div class="container">
<h2>Register Account</h2>
<br/><br/>
<form id="register-form">
<div class="form-group has-info label-static is-empty">
<label for="username" class="control-label">Username</label>
<input id="username" name="username" class="form-control" type="text" placeholder="Choose a username"/>
</div>
<div class="form-group has-info label-static is-empty">
<label for="display_name" class="control-label">Full Name</label>
<input id="display_name" name="name" class="form-control" type="text" placeholder="Enter your full name"/>
</div>
<div class="form-group has-info label-static is-empty">
<label for="email" class="control-label">Email Address</label>
<input id="email" name="email" class="form-control" type="email" placeholder="Enter your email"/>
</div>
<div class="form-group has-info label-static is-empty">
<label for="password" class="control-label">Password</label>
<input id="password" name="password" class="form-control" type="password" placeholder="Make a password"/>
</div>
<button type="submit" class="btn btn-raised btn-info">Submit<div class="ripples-container"></div></button>
</form>
</div>
code of RegisterModel.py:
import pymongo
from pymongo import MongoClient
class RegisterModel:
def __int__(self):
self.client = MongoClient()
self.db = self.client.codewizard
self.Users = self.db.users
def insert_user(self, data):
id = self.Users.insert({"username": data.username, "name": data.name, "password": data.password, "email": data.email})
print("uid is", id)