plan apilar qoshildi

This commit is contained in:
behruz-dev
2025-11-24 15:45:50 +05:00
parent b97cbd5786
commit cafc32b5d3
5 changed files with 138 additions and 0 deletions

View File

@@ -0,0 +1,25 @@
# django
from django.db import transaction
# rest framework
from rest_framework import serializers
# shared
from core.apps.shared.models import Plan
class PlanSerializer(serializers.ModelSerializer):
class Meta:
model = Plan
fields = [
'id', 'title', 'description', 'date', 'is_done', 'created_at'
]
def create(self, validated_data):
with transaction.atomic():
return Plan.objects.create(
title=validated_data.get('title'),
description=validated_data.get('description'),
date=validated_data.get('date'),
user=self.context.get('user'),
)