【问题标题】:django tastypie filter a non orm fielddjango tastepie 过滤一个非 orm 字段
【发布时间】:2015-05-04 05:02:12
【问题描述】:

我正在尝试在 django sweetpie 中创建一个网络服务。在我的模型中,我有

class Temp((models.Model):
    name = models.CharField(max_length=50)

    @property
    def modelNumber(self):  
        return self.name + '/' + str(self.id)

在我的资源中

class TempResource(ModelResource) :
    modelNumber = fields.CharField(attribute='modelNumber', readonly=True)
    class Meta:
        queryset = Temp.objects.all()
        filtering = {'modelNumber':ALL}

我尝试提出请求 /temp/?modelNumber=NRA/1 。我收到无法将关键字“modelNumber”解析为字段的错误。

【问题讨论】:

    标签: python django tastypie


    【解决方案1】:

    可能是与 url 中的原始“/”有关吗?

    【讨论】:

      猜你喜欢
      • 2021-10-23
      • 2019-07-06
      • 2020-06-06
      • 2013-09-29
      • 2020-08-28
      • 2017-07-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多