Skip to content

Commit

Permalink
chore: date format
Browse files Browse the repository at this point in the history
  • Loading branch information
MustafaMunir123 committed Dec 2, 2023
1 parent 708b31d commit b0fecbe
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 5 deletions.
6 changes: 2 additions & 4 deletions apps/transactions/api/v1/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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)
Expand Down
18 changes: 18 additions & 0 deletions apps/transactions/migrations/0023_alter_transaction_date.py
Original file line number Diff line number Diff line change
@@ -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(),
),
]
4 changes: 3 additions & 1 deletion apps/transactions/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Binary file modified db.sqlite3
Binary file not shown.

0 comments on commit b0fecbe

Please sign in to comment.