from rest_framework import serializers
from rest_framework import relations
from api.models import SimpleOffer, ObjectCategory, ObjectSubCategory, HelpTimeSearch

class RefugeeCampSerializer(serializers.Serializer):
    id = serializers.IntegerField(read_only=True)

    city = serializers.CharField()
    postcode = serializers.CharField()
    street = serializers.CharField()
    streetnumber = serializers.CharField()

class ObjectCategorySerializer(serializers.Serializer):
    id = serializers.IntegerField(read_only=True)

    title = serializers.CharField()

    def create(self, validated_data):
        return ObjectCategory.objects.create(**validated_data)

    def update(self, instance, validated_data):
        instance.title = validated_data.get('title', instance.title)
        instance.save()
        return instance

class ObjectSubCategorySerializer(serializers.Serializer):
    id = serializers.IntegerField(read_only=True)
    parent = relations.PrimaryKeyRelatedField(queryset=ObjectCategory.objects.all())

    title = serializers.CharField()

    def create(self, validated_data):
        return ObjectSubCategory.objects.create(**validated_data)

    def update(self, instance, validated_data):
        instance.parent = validated_data.get('parent', instance.parent)
        instance.title = validated_data.get('title', instance.title)
        instance.save()
        return instance

class SimpleOfferSerializer(serializers.Serializer):
    id = serializers.IntegerField(read_only=True)

    category = relations.PrimaryKeyRelatedField(queryset=ObjectCategory.objects.all())
    title = serializers.CharField()
    description = serializers.CharField(max_length=4096)
    create_time = serializers.DateTimeField()
    image = serializers.ImageField(allow_null=True)

    city = serializers.CharField()
    telephone = serializers.CharField()
    email = serializers.EmailField()

    def create(self, validated_data):
        return SimpleOffer.objects.create(**validated_data)

    def update(self, instance, validated_data):
        instance.category = validated_data.get('category', instance.category)
        instance.title = validated_data.get('title', instance.title)
        instance.description = validated_data.get('description', instance.description)
        instance.image = validated_data.get('image', instance.image)
        instance.city = validated_data.get('city', instance.city)
        instance.telephone = validated_data.get('telephone', instance.telephone)
        instance.email = validated_data.get('email', instance.email)
        instance.save()
        return instance

class HelpTimeSearchSerializer(serializers.Serializer):
    id = serializers.IntegerField(read_only=True)

    start_time = serializers.DateTimeField()
    end_time = serializers.DateTimeField()

    email = serializers.EmailField()

    def create(self, validated_data):
        return HelpTimeOffer.objects.create(**validated_data)

    def update(self, instance, validated_data):
        instance.start_time = validated_data.get('start_time', instance.start_time)
        instance.end_time = validated_data.get('end_time', instance.end_time)
        instance.email = validated_data.get('email', instance.email)
        instance.save()
        return instance

@@ -296,24 +296,37 @@
 s.CharField(
+max_length=64
 )%0D%0A    postc
@@ -345,32 +345,45 @@
 izers.CharField(
+max_length=16
 )%0D%0A    street = 
@@ -400,24 +400,38 @@
 s.CharField(
+max_length=128
 )%0D%0A    stree
@@ -458,24 +458,37 @@
 s.CharField(
+max_length=32
 )%0D%0A%0D%0Aclass O
@@ -616,32 +616,45 @@
 izers.CharField(
+max_length=64
 )%0D%0A%0D%0A    def cre
@@ -1147,24 +1147,37 @@
 s.CharField(
+max_length=64
 )%0D%0A%0D%0A    def
@@ -1746,24 +1746,37 @@
 s.CharField(
+max_length=64
 )%0D%0A    descr
@@ -1955,24 +1955,37 @@
 s.CharField(
+max_length=64
 )%0D%0A    telep
@@ -2009,24 +2009,37 @@
 s.CharField(
+max_length=64
 )%0D%0A    email
@@ -2056,32 +2056,46 @@
 zers.EmailField(
+max_length=128
 )%0D%0A%0D%0A    def cre
@@ -3010,24 +3010,24 @@
 eField()%0D%0A%0D%0A
-
     email = 
@@ -3045,24 +3045,38 @@
 .EmailField(
+max_length=128
 )%0D%0A%0D%0A    def

Add max. length to serializers