Python rest_framework.fields.DateTimeField() Examples
The following are 2
code examples of rest_framework.fields.DateTimeField().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
rest_framework.fields
, or try the search function
.
Example #1
Source File: serializers.py From karrot-backend with GNU Affero General Public License v3.0 | 5 votes |
def get_updated_at(self, participant): if participant.updated_at > participant.conversation.updated_at: date = participant.updated_at else: date = participant.conversation.updated_at return DateTimeField().to_representation(date)
Example #2
Source File: mbox.py From patchew with MIT License | 5 votes |
def get_json(self): """Return the JSON format of the mbox """ msg = {} msg["message_id"] = self.get_message_id() msg["in_reply_to"] = self.get_in_reply_to() or "" msg["date"] = DateTimeField().to_representation(self.get_date()) msg["subject"] = self.get_subject() msg["sender"] = addr_db_to_rest(self.get_from()) msg["recipients"] = [ addr_db_to_rest(x) for x in (self.get_to() + self.get_cc()) ] msg["mbox"] = self.get_mbox() return msg