money_dance
money_dance

Reputation: 105

Django User Creation without Form

I am building an analytics platform for our app.

To create users who can access the analytics platform I am choosing existing user's from our app that do no utilize djangos user model. I then plan to create a django user for the selected user so I can use djangos built in authentication.

I have seen many examples of creating django users with a form, but instead of writing an email into a textbox I am choosing an existing user on our app from a search list.

Because of this I don't think I can utilize a form and am wondering how I should go about creating a user?

I was planning on sending the user I selected's id and the password to the view that would create the user with AJAX.

Upvotes: 2

Views: 2866

Answers (1)

catavaran
catavaran

Reputation: 45575

Just call the create_user() method:

from django.contrib.auth.models import User

User.objects.create_user(username='somename', password='somepass')

Upvotes: 10

Related Questions