I would like to check if the username given during the registration of a user already exists using pymodm with a clear solution similar to this one using pymongo:
if users.find_one({"username": username}) is not None:
print("This username already exists")
To make this code I would have to write :
try :
user = User.objects.get({'username': username})
except errors.DoesNotExist:
user = None
if user is not None:
print("This username already exists")
Because pymodm uses expections. It is very inefficient and heavy to code. Do you have any idea ?