from rest_framework import serializers
from tweets.models import Tweet
from useraccounts.api.serializers import UserDataSerializer
from django.utils.timesince import timesince
class TweetModelSerializer(serializers.ModelSerializer):
    user = UserDataSerializer(read_only=True)
    date_display = serializers.SerializerMethodField()
    timesince = serializers.SerializerMethodField()

    class Meta:
        model = Tweet
        fields = [
            'user',
            'content',
            'timestamp',
            'date_display',
            'timesince',
        ]
    def get_date_display(self,obj):
        return obj.timestamp.strftime("%b %d, at %I:%M %p")
    def get_timesince(self,obj):
        return timesince(obj.timestamp)

64840eb72a5ed243a3ee73b7527e281d0c8ae933
<mask token>


class TweetModelSerializer(serializers.ModelSerializer):
    <mask token>
    <mask token>
    <mask token>


    class Meta:
        model = Tweet
        fields = ['user', 'content', 'timestamp', 'date_display', 'timesince']
    <mask token>

    def get_timesince(self, obj):
        return timesince(obj.timestamp)

<mask token>


class TweetModelSerializer(serializers.ModelSerializer):
    <mask token>
    <mask token>
    <mask token>


    class Meta:
        model = Tweet
        fields = ['user', 'content', 'timestamp', 'date_display', 'timesince']

    def get_date_display(self, obj):
        return obj.timestamp.strftime('%b %d, at %I:%M %p')

    def get_timesince(self, obj):
        return timesince(obj.timestamp)

<mask token>


class TweetModelSerializer(serializers.ModelSerializer):
    user = UserDataSerializer(read_only=True)
    date_display = serializers.SerializerMethodField()
    timesince = serializers.SerializerMethodField()


    class Meta:
        model = Tweet
        fields = ['user', 'content', 'timestamp', 'date_display', 'timesince']

    def get_date_display(self, obj):
        return obj.timestamp.strftime('%b %d, at %I:%M %p')

    def get_timesince(self, obj):
        return timesince(obj.timestamp)

from rest_framework import serializers
from tweets.models import Tweet
from useraccounts.api.serializers import UserDataSerializer
from django.utils.timesince import timesince


class TweetModelSerializer(serializers.ModelSerializer):
    user = UserDataSerializer(read_only=True)
    date_display = serializers.SerializerMethodField()
    timesince = serializers.SerializerMethodField()


    class Meta:
        model = Tweet
        fields = ['user', 'content', 'timestamp', 'date_display', 'timesince']

    def get_date_display(self, obj):
        return obj.timestamp.strftime('%b %d, at %I:%M %p')

    def get_timesince(self, obj):
        return timesince(obj.timestamp)

from rest_framework import serializers
from tweets.models import Tweet
from useraccounts.api.serializers import UserDataSerializer
from django.utils.timesince import timesince
class TweetModelSerializer(serializers.ModelSerializer):
    user = UserDataSerializer(read_only=True)
    date_display = serializers.SerializerMethodField()
    timesince = serializers.SerializerMethodField()

    class Meta:
        model = Tweet
        fields = [
            'user',
            'content',
            'timestamp',
            'date_display',
            'timesince',
        ]
    def get_date_display(self,obj):
        return obj.timestamp.strftime("%b %d, at %I:%M %p")
    def get_timesince(self,obj):
        return timesince(obj.timestamp)
