A
A
Alexander2016-06-02 11:22:44
Django
Alexander, 2016-06-02 11:22:44

Djnago parler does not return the translation?

admin.py:

products = Product.objects.filter(translations__title__contains=request.POST['text'])[:10]
return HttpResponse(serializers.serialize('json', products))

answer:
[{"model": "products.product", "pk": 2, "fields": {"alias": "Kran-so-shlangom", "category": 1, "status": true, "show_on_main": true, "discounts": true, "guarantee": true, "setting": true, "size": "", "uzs": null, "usd": null, "pricelist": ""}}]

it returned all fields except for the ones here:
translations = TranslatedFields(
title=models.CharField(max_length=60, verbose_name="Title"),
short_text=models.CharField(max_length=80, verbose_name="Short text"),
text =models.TextField(verbose_name="Description"),
)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Владимир Куц, 2016-06-02
@kentuck1213

Напишите свой сериализатор.
Гляньте как это организовано в django-parler-rest , и сделайте по образу и подобию.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question