gault-millau/apps/comment/transfer_data.py
2019-11-05 16:45:43 +05:00

22 lines
581 B
Python

from pprint import pprint
from transfer.models import Comments
from transfer.serializers.comments import CommentSerializer
def transfer_comments():
queryset = Comments.objects.filter(account__isnull=False, mark__isnull=False)\
.only("id", "comment", "mark", "locale", "establishment_id", "account_id")
serialized_data = CommentSerializer(data=list(queryset.values()), many=True)
if serialized_data.is_valid():
serialized_data.save()
else:
pprint(serialized_data.errors)
data_types = {
"comment": [
transfer_comments
]
}