Spaces:
Runtime error
Runtime error
Download dashboard/serializers.py from OLETECH/BUSINESSTRACKER: direct link, hf CLI and curl.
- Browser
- Download file 787 Bytes
-
https://huggingface.co/spaces/OLETECH/BUSINESSTRACKER/resolve/main/dashboard/serializers.py
- Command line
-
hf download hf://spaces/OLETECH/BUSINESSTRACKER/dashboard/serializers.py
-
curl -L -o serializers.py https://huggingface.co/spaces/OLETECH/BUSINESSTRACKER/resolve/main/dashboard/serializers.py
787 Bytes
| from rest_framework import serializers | |
| from .models import Sale, Expense | |
| class SaleSerializer(serializers.ModelSerializer): | |
| """Serializes sale data — total is auto calculated in model""" | |
| class Meta: | |
| model = Sale | |
| fields = [ | |
| 'id', 'item_name', 'quantity', | |
| 'unit_price', 'total', 'date', 'created_at' | |
| ] | |
| # Total is calculated automatically, no need to send it | |
| read_only_fields = ['total', 'created_at'] | |
| class ExpenseSerializer(serializers.ModelSerializer): | |
| """Serializes expense data""" | |
| class Meta: | |
| model = Expense | |
| fields = [ | |
| 'id', 'description', 'amount', | |
| 'category', 'date', 'created_at' | |
| ] | |
| read_only_fields = ['created_at'] |