From b0fecbef5e483af4955425887c3053271c157a25 Mon Sep 17 00:00:00 2001 From: MustafaMunir123 Date: Sat, 2 Dec 2023 13:40:55 +0500 Subject: [PATCH] chore: date format --- apps/transactions/api/v1/serializers.py | 6 ++---- .../migrations/0023_alter_transaction_date.py | 18 ++++++++++++++++++ apps/transactions/models.py | 4 +++- db.sqlite3 | Bin 212992 -> 212992 bytes 4 files changed, 23 insertions(+), 5 deletions(-) create mode 100644 apps/transactions/migrations/0023_alter_transaction_date.py diff --git a/apps/transactions/api/v1/serializers.py b/apps/transactions/api/v1/serializers.py index 728470f..d9394c2 100644 --- a/apps/transactions/api/v1/serializers.py +++ b/apps/transactions/api/v1/serializers.py @@ -23,10 +23,7 @@ def update(self, instance, validated_data): class TransactionSerializer(serializers.ModelSerializer): - read_only_fields = ( - "date", - "time", - ) + read_only_fields = ("time",) from_account = AccountSerializer(read_only=True) to_account = AccountSerializer(read_only=True) @@ -48,6 +45,7 @@ class Meta: "time", "is_archived", ] + extra_kwargs = {"date": {"format": "%d-%m-%Y"}} def create(self, validated_data): return Transaction.objects.create(**validated_data) diff --git a/apps/transactions/migrations/0023_alter_transaction_date.py b/apps/transactions/migrations/0023_alter_transaction_date.py new file mode 100644 index 0000000..4ee0584 --- /dev/null +++ b/apps/transactions/migrations/0023_alter_transaction_date.py @@ -0,0 +1,18 @@ +# Generated by Django 3.2.6 on 2023-12-02 08:26 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('transactions', '0022_transaction_is_archived'), + ] + + operations = [ + migrations.AlterField( + model_name='transaction', + name='date', + field=models.DateField(), + ), + ] diff --git a/apps/transactions/models.py b/apps/transactions/models.py index 046043f..5ae135e 100644 --- a/apps/transactions/models.py +++ b/apps/transactions/models.py @@ -50,7 +50,9 @@ class Transaction(models.Model): entry_no = models.IntegerField(auto_created=False, primary_key=True) from_account = models.ForeignKey(Account, on_delete=models.CASCADE, related_name="transactions_from") to_account = models.ForeignKey(Account, on_delete=models.CASCADE, related_name="transactions_to") - date = models.DateField(auto_now_add=True) + date = models.DateField( + auto_now_add=False, + ) time = models.TimeField(auto_now_add=True) from_currency = models.CharField(max_length=3, null=False, blank=False, choices=CURRENCY_CHOICES) to_currency = models.CharField(max_length=3, null=False, blank=False, choices=CURRENCY_CHOICES) diff --git a/db.sqlite3 b/db.sqlite3 index 6b5dcefeecde43dc05f87db9141fb4ede4867309..0a180029be682f88fe680ca6fc5a4f3c38a0f0e3 100644 GIT binary patch delta 2289 zcma)7eQX@X72lcl?cT=TnKKCqu7RAtLcsBP_T%>UF8;bZoH!xpIx-hTOmta$*N$VK z@8VtGIS$}6trYPGRZyy~B7qtt=s!hm!7Zyw6wyenDj`)A2`Neh1gWZ8)QTWMDvA`C zT_?l@qq5q0v)Xy@_dez~^J+D*Ruj)OH`)xtsB|>a!P4>Cv%3^vzjE|N%*NP{&hn8l zz}CRrr}sJUFwqLE+R*Xo|3hc zEX8D5Nyhb6dCNreHf{^gb^-IaF*j8z7-n&Lt}t7gN}qkXy92~l-|3dg9X#5?;Medh zZbkn@&!Ym`vf2{8E_Uu~!c6Dp%@6`1ApjxVA}J{)o+5fIu1H!UnIC;HJ@_Ep1&`Fb z=P|prc`X*wC6OL6Fa^|fdtmC$A-3&n1)}Y1xP=V_itWCPSdzbqKs3ERP!Q;|Jy4MJ z6n*7HOjn7fD7nMK^tDSxE9zK_4!mVKwCM)4a3gHD7qi{#d=Ck?E1bSfA$+^S->5?L zmWxev2YGy%!C&BO_!InZd>Q`(Us-Le{RxNaSOGM-R|+utYOTH|-bYm>I{bOZYD@WX z?EMsj^7*^c=oEwgfL=krL@%MAqjTsidIqhaQ*PupU>2g&bPqle-K!YZ?cmZO765L* zmks^FcV8fT1KAVE-QG)YfC6CC=yjKW6D%Nf3B8NnMsJ}%qd%h8DV&Vj{NU2Q81O~E zFZz7Z>x&*=?DjtRE67E&l02^JRzgZz8c9r&aVf6E&4e*2k884_7!!It5jR!KSS!jJ z|Fo1Ur_^MONF<>pIj{6F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