Spaces:
Running
Running
Download api/serializers/projects.py from Dayozoe/harvestconnect-api: direct link, hf CLI and curl.
- Browser
- Download file 981 Bytes
-
https://huggingface.co/spaces/Dayozoe/harvestconnect-api/resolve/main/api/serializers/projects.py
- Command line
-
hf download hf://spaces/Dayozoe/harvestconnect-api/api/serializers/projects.py
-
curl -L -o projects.py https://huggingface.co/spaces/Dayozoe/harvestconnect-api/resolve/main/api/serializers/projects.py
981 Bytes
| from rest_framework import serializers | |
| from django.contrib.auth.models import User | |
| from ..models import Project | |
| from .common import UserSerializer | |
| class ProjectSerializer(serializers.ModelSerializer): | |
| tradesman = UserSerializer(read_only=True) | |
| client = UserSerializer(read_only=True) | |
| tradesman_id = serializers.PrimaryKeyRelatedField( | |
| queryset=User.objects.all(), | |
| source='tradesman', | |
| write_only=True, | |
| required=False | |
| ) | |
| client_id = serializers.PrimaryKeyRelatedField( | |
| queryset=User.objects.all(), | |
| source='client', | |
| write_only=True, | |
| required=False | |
| ) | |
| class Meta: | |
| model = Project | |
| fields = [ | |
| 'id', 'tradesman', 'tradesman_id', 'client', 'client_id', 'title', 'description', | |
| 'status', 'priority', 'budget', 'start_date', 'end_date', 'images', | |
| 'created_at', 'updated_at' | |
| ] | |
| read_only_fields = ['id', 'created_at', 'updated_at'] | |