If you want to create a user, you can try the following:
user = User.objects.create_user(username=new_data['username'], email=new_data['email']) print user.pk
By the way, this also normalizes the email address and thatβs it.
If you need to assign other parameters, such as a name, just use your custom variable, assign these values ββand then save.
You should read about model managers if you want more information about this.
source share