I have no problem with MongoCompass (localhost), but when i am trying to make everything with Mongo Atlas (to deploy then in heroku), I have error:
line 61, in post
if len(list(mongo.db.user.find({'studentId': args['studentId']}))) == 0:
AttributeError: 'NoneType' object has no attribute 'user'
my code:
class User(Resource):
def post(self):
args = user_put_args.parse_args()
if len(list(mongo.db.user.find({'studentId': args['studentId']}))) == 0:
args['events'] = []
organisers_f = open(f'{os.path.dirname(os.path.abspath(__file__))}/organisers.txt', 'r')
organisers = [l.strip() for l in organisers_f.readlines()]
args['permission'] = 0
if args['studentId'] in organisers:
args['permission'] = 1
args['organisedEvents'] = []
result = mongo.db.user.insert_one(args)
print(result.inserted_id)
return {'id': str(result.inserted_id), 'permission': args['permission']}