Thank you for developing such an excellent plugin. I have found that when encountering django lazy loading, an error will be reported. The following example can reproduce this problem:
from django.db import models
from django.utils.translation import gettext_lazy as _
class MyModel(models.Model):
STATUS_CHOICES = (
('Created', _('Created')),
('Processing', _('Processing')),
('Finished', _('Finished')),
)
status = models.CharField(choices=STATUS_CHOICES)
...
from rest_framework import serializers
class MySerializers(serializers.ModelSerializer):
status_display = serializers.CharField(source='get_status_display')
class Meta:
model = MyModel
fields = ('status', 'status_display')
Only use gettext_ Lazy only has this issue, and gettext does not. I have analyzed that the reason for the problem is that lazy returned a obj of __ proxy__(a subclass of Promise) type , which is not a common data type.
I tried to fix this issue and submitted a merge request, which may not be elegant, but at least it works.
Thank you for developing such an excellent plugin. I have found that when encountering django lazy loading, an error will be reported. The following example can reproduce this problem:
Only use
gettext_ Lazy
only has this issue, andgettext
does not. I have analyzed that the reason for the problem is thatlazy
returned a obj of__ proxy__
(a subclass ofPromise
) type , which is not a common data type.I tried to fix this issue and submitted a merge request, which may not be elegant, but at least it works.