alpinesmuseum-public/catalog/serializers.py
2022-09-23 07:38:37 +05:30

15 lines
496 B
Python

from rest_framework.serializers import ModelSerializer
from . import models
from cms.utils import get_current_site
class CommentSerializer(ModelSerializer):
class Meta:
model = models.Comment
exclude = ["id", "item", "added_on", "status", "admin_comment", "site"]
def create(self, validated_data):
comment = models.Comment.objects.create(
**validated_data,
site=get_current_site(self.context['request'])
)
return comment