开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜