def to_representation()
с дочерним сериализаторомVendorManagementUpdateSerializer
определяем метод def to_representation(self, instance):
response = super().to_representation(instance)
response['parent'] = VendorToFrontSerializer(instance.parent).data
return response
/api/v1/vendors/from_csv_create/
services:
- mysql:5.7
variables:
MYSQL_DATABASE: "db_name"
MYSQL_ROOT_PASSWORD: "dbpass"
MYSQL_USER: "username"
MYSQL_PASSWORD: "dbpass"
stages:
- test
test:
stage: test
before_script:
- apt update -qy && apt-get install -qqy --no-install-recommends default-mysql-client
- mysql --user=$MYSQL_USER --password=$MYSQL_PASSWORD --database=$MYSQL_DATABASE --host=$MYSQL_HOST --execute="SHOW DATABASES; ALTER USER '$MYSQL_USER'@'%' IDENTIFIED WITH mysql_native_password BY '$MYSQL_PASSWORD'"
script:
- apt update -qy
- apt install python3 python3-pip virtualenvwrapper -qy
- virtualenv --python=python3 venv/
- source venv/bin/activate
- pwd
- pip install -r requirement.txt
- python manage.py test apps
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
mysql --protocol=TCP --user=$MYSQL_USER --password=$MYSQL_PASSWORD --database=$MYSQL_DATABASE --host=$MYSQL_HOST --execute="SHOW DATABASES; ALTER USER '$MYSQL_USER'@'%' IDENTIFIED WITH mysql_native_password BY '$MYSQL_PASSWORD'"
ERROR 2002 (HY000): Can't connect to MySQL server on 'localhost' (99)
class VendorsSerializer(serializers.ModelSerializer):
contacts = VendorContactSerializer(many=True)
nda = serializer.DateField( ???? )
class Meta:
model = Vendors
fields = ('vendor_name',
'country',
'nda',
'contacts',)
class Vendors(models.Model):
...
nda = models.DateField(blank=True, null=True)
def clean(self):
if self.nda == "":
self.nda = None
clean()