本文整理汇总了Python中api.models.User.updated_at方法的典型用法代码示例。如果您正苦于以下问题:Python User.updated_at方法的具体用法?Python User.updated_at怎么用?Python User.updated_at使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类api.models.User
的用法示例。
在下文中一共展示了User.updated_at方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: POST_users
# 需要导入模块: from api.models import User [as 别名]
# 或者: from api.models.User import updated_at [as 别名]
def POST_users(request, format):
""" Respond to the "POST users" request.
We create a new user and log them in.
"""
# Get the request parameters.
params = apiHelper.get_params(request, resource_name="user")
error = apiHelper.check_params(params,
required_params=[],
optional_params=["username", "password"])
if error != None: return error
username = params.get("username")
password = params.get("password")
if username == "": username = None
if password == "": password = None
# Check that the given username doesn't already exist.
if username != None:
if User.objects.filter(username=username).exists():
return HttpResponseBadRequest("Duplicate User")
# Create a new User object for this user.
user = User()
user.username = username
if password != None:
user.set_password(password)
user.created_at = datetime.datetime.now()
user.updated_at = datetime.datetime.now()
user.save()
# Open up a session for this new user.
token = session.create(user)
# Finally, return the newly-created user and the login token back to the
# caller.
return apiHelper.response({'user' : user.to_dict(),
'token' : token},
format=format, status=HTTP_RESPONSE_POST_OK)