本文整理汇总了Python中models.Message.timestamp方法的典型用法代码示例。如果您正苦于以下问题:Python Message.timestamp方法的具体用法?Python Message.timestamp怎么用?Python Message.timestamp使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Message
的用法示例。
在下文中一共展示了Message.timestamp方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create
# 需要导入模块: from models import Message [as 别名]
# 或者: from models.Message import timestamp [as 别名]
def create(self):
new_message = Message()
new_message.customer_number = "1234567890"
new_message.product_code = str(random.randrange(100, 999))
new_message.shop_code = "123"
new_message.timestamp = datetime.now()
new_message.notified = False
return new_message
示例2: _parse_query
# 需要导入模块: from models import Message [as 别名]
# 或者: from models.Message import timestamp [as 别名]
def _parse_query(self, query_params):
shop_code = query_params.reply[:3]
product_code = query_params.reply[3:]
if not (Shop(shop_code).is_valid() and Product(product_code).is_valid()):
raise Exception('Invalid product or shop code.')
message = Message()
message.customer_number = query_params.cellno
message.product_code = product_code
message.shop_code = shop_code
message.timestamp = query_params.replydate #TODO: date conversion
return message
示例3: Http404
# 需要导入模块: from models import Message [as 别名]
# 或者: from models.Message import timestamp [as 别名]
host: The hostname of the computer the client is running on
"""
if request.method != "POST":
print "Did not post"
raise Http404("You must post to this URL")
receiver_account = get_or_create_account(protocol, request.POST["receiver_account"], request.POST["owner_account"])
sender_account = get_or_create_account(protocol, request.POST["sender_account"], request.POST["owner_account"])
if sender_account.full_name == "":
sender_account.full_name = request.POST["alias"]
sender_account.save()
try:
timestamp = datetime.datetime.strptime(request.POST["timestamp"][:-6], "%Y-%m-%dT%H:%M:%S")
except Exception, e:
print e.message
timestamp = datetime.datetime.strptime(request.POST["timestamp"][:-6], "%Y-%m-%d %H:%M:%S")
messages = Message.objects.filter(sender=sender_account).filter(receiver=receiver_account).filter(timestamp=timestamp)
if len(messages) > 0:
return HttpResponse(simplejson.dumps({"result":False,"reason":"Duplicate message"}), mimetype="application/json")
message = Message()
message.receiver = receiver_account
message.sender = sender_account
message.timestamp = timestamp
message.text = request.POST["message_text"]
message.client_type = request.POST["client_type"]
message.host = request.POST["host"]
message.save()
data = simplejson.dumps({"result":True})
return HttpResponse(data, mimetype="application/json")