Answer the question
In order to leave comments, you need to log in
How to make an array for a JSON field of an object?
There was such a problem. I can pass json format object
[
{
"title": "test",
"address": "55.99752311227003,49.08959250252893"
},
{
"title": "test122",
"address": "63.08891623673952,46.243883499999946"
},
{
"title": "test1111",
"address": "55.69684742706125,37.59635133512744"
},
{
"title": "kgeu",
"address": "55.816852257889856,49.09529045886616"
}
]
[
{
"title": "kgeu",
"address": [55.816852257889856,49.09529045886616]
}
]
REST_FRAMEWORK = {
'DEFAULT_RENDERER_CLASSES': (
'rest_framework.renderers.JSONRenderer',
'rest_framework.renderers.BrowsableAPIRenderer',
),
'DEFAULT_PARSER_CLASSES': (
'rest_framework.parsers.JSONParser',
)
}
class FactorySerializer(serializers.ModelSerializer):
class Meta:
model = Factory
fields = ['title', 'address']
class FactoryListView(generics.ListCreateAPIView):
queryset = Factory.objects.all()
serializer_class = FactorySerializer
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question