开发者

WIth django, can you do something similiar to user = User.new(params[:user]) during a form post?

开发者 https://www.devze.com 2023-01-23 12:52 出处:网络
in ruby/ror you can do this: user = User.new(params[:user]) which populates a new object with the values from a posted form.

in ruby/ror you can do this:

user = User.new(params[:user])

which populates a new object with the values from a posted form.

Can something similar be do开发者_如何学Gone using django/python?


Look at the model form documentation. Basically, the code would look like:

f = UserForm(request.POST or None)
user = f.save()


If you are talking about Django's built-in auth app, then keep in mind that there are a few considerations when creating users, such as passwords, unique usernames, etc

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号