fixed serializers
This commit is contained in:
parent
f65b1caf9a
commit
b5c50ff730
|
|
@ -1,20 +1,35 @@
|
||||||
from rest_framework import serializers
|
from rest_framework import serializers
|
||||||
|
|
||||||
from collection import models
|
from collection import models
|
||||||
|
from gallery import models as gallery_models
|
||||||
|
|
||||||
|
|
||||||
class CollectionSerializer(serializers.ModelSerializer):
|
class CollectionSerializer(serializers.ModelSerializer):
|
||||||
"""Collection serializer"""
|
"""Collection serializer"""
|
||||||
image = serializers.URLField(source='image.get_image_url')
|
filters = serializers.JSONField(required=True)
|
||||||
|
selectors = serializers.JSONField(required=True)
|
||||||
|
targets = serializers.JSONField(required=True)
|
||||||
|
block_size = serializers.JSONField(required=True)
|
||||||
|
image = serializers.PrimaryKeyRelatedField(
|
||||||
|
queryset=gallery_models.Image.objects.all(), required=True)
|
||||||
|
is_publish = serializers.BooleanField(required=True)
|
||||||
|
on_top = serializers.BooleanField(required=True)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = models.Collection
|
model = models.Collection
|
||||||
fields = [
|
fields = [
|
||||||
'id',
|
'id',
|
||||||
'name',
|
'name',
|
||||||
'block_size',
|
'start',
|
||||||
|
'end',
|
||||||
'image',
|
'image',
|
||||||
'on_top'
|
'is_publish',
|
||||||
|
'on_top',
|
||||||
|
'filters',
|
||||||
|
'selectors',
|
||||||
|
'targets',
|
||||||
|
'country',
|
||||||
|
'block_size',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,8 +8,8 @@ app_name = 'collection'
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path('list/', views.CollectionListView.as_view(),
|
path('list/', views.CollectionListView.as_view(),
|
||||||
name='collections_list'),
|
name='collections_list'),
|
||||||
# path('create/', views.CollectionCreateView.as_view(),
|
path('create/', views.CollectionCreateView.as_view(),
|
||||||
# name='collection_create'),
|
name='collection_create'),
|
||||||
# path('<int:pk>/', views.CollectionRetrieveView.as_view(),
|
# path('<int:pk>/', views.CollectionRetrieveView.as_view(),
|
||||||
# name='collection_retrieve'),
|
# name='collection_retrieve'),
|
||||||
# path('<int:pk>/delete/', views.CollectionDestroyView.as_view(),
|
# path('<int:pk>/delete/', views.CollectionDestroyView.as_view(),
|
||||||
|
|
|
||||||
|
|
@ -10,5 +10,6 @@ class ImageSerializer(serializers.ModelSerializer):
|
||||||
"""Meta class"""
|
"""Meta class"""
|
||||||
model = models.Image
|
model = models.Image
|
||||||
fields = (
|
fields = (
|
||||||
|
'id',
|
||||||
'image',
|
'image',
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
from rest_framework import serializers
|
from rest_framework import serializers
|
||||||
|
|
||||||
|
from gallery import models as gallery_models
|
||||||
from location.models import Address
|
from location.models import Address
|
||||||
from location.serializers import AddressSerializer
|
from location.serializers import AddressSerializer
|
||||||
from news import models
|
from news import models
|
||||||
|
|
@ -51,7 +52,8 @@ class NewsCreateUpdateSerializer(NewsSerializer):
|
||||||
title = serializers.JSONField()
|
title = serializers.JSONField()
|
||||||
subtitle = serializers.JSONField()
|
subtitle = serializers.JSONField()
|
||||||
description = serializers.JSONField()
|
description = serializers.JSONField()
|
||||||
image = serializers.ImageField(required=True)
|
image = serializers.PrimaryKeyRelatedField(
|
||||||
|
queryset=gallery_models.Image.objects.all(), required=True,)
|
||||||
news_type = serializers.PrimaryKeyRelatedField(
|
news_type = serializers.PrimaryKeyRelatedField(
|
||||||
queryset=models.NewsType.objects.all(), write_only=True)
|
queryset=models.NewsType.objects.all(), write_only=True)
|
||||||
address = serializers.PrimaryKeyRelatedField(
|
address = serializers.PrimaryKeyRelatedField(
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user