Reputation: 33
i am wondering if the below code is valid as there is no method assigned after objects. However it seem to be working in my code. How is this happened as "create" is only a part of my own defined method (create_user), the computer shouldn't understand my method as it is not a build-in method
def create_user(self, username, email, password):
new_user = User.objects.create_user(username, email, password)
new_user.save()
is the string "create" work in some way? or "objects" will create database in the absence of assigned method by default?
Upvotes: 0
Views: 68
Reputation: 799082
From the docs:
By default, Django adds a
Manager
with the nameobjects
to every Django model class.
Upvotes: 1