from rest_framework.serializers import (
	ModelSerializer,
	SerializerMethodField,

	)
 
from .models import Hashtag






class HashtagSerializer( ModelSerializer):
	

	user  =  SerializerMethodField()
	avatar = SerializerMethodField()
	class Meta:
		model 	=	Hashtag
		fields	=	[
			'id',
			'user',
			'avatar',
			'story',
			'hashtag',
			'created_at',	
		]


		

	def get_user(self, obj):
		return str(obj.user.profile.username)



	def get_avatar(self,obj):
		try:
			avatar = str(obj.user.profile.avatar)
		except:
			avatar = None
		return avatar

