【问题标题】:Tastypie with Django 1.8 giving Content type not found errorTastypie with Django 1.8 给出 Content type not found 错误
【发布时间】:2015-09-15 19:17:53
【问题描述】:

在尝试将我的 TastyPie 应用升级到 Django 1.8 但收到错误消息:

找不到指定类型“html”的内容类型。请在类级别或通过参数提供它。

在以下 Python 代码中执行 serializer=... 时会发生这种情况:

class PeopleResource(ModelResource):
    movie = fields.ToManyField('movies.api.MovieResource', 'movie', related_name="casts", null=True)      
    class Meta:
        queryset = People.objects.all()
        resource_name = 'people'
        include_resource_uri = False
        always_return_data = True
        authorization= Authorization()
        serializer = Serializer(formats=['json', 'jsonp', 'xml', 'yaml', 'html', 'plist'])
        filtering = {
            'name': ALL,
            'id': ALL,
        }

我不明白在类级别或按参数提供的说明。

【问题讨论】:

  • 嗯,如果你把html从格式列表中去掉,还能用吗?
  • 是的,如果我删除 'html' 就可以了

标签: python django tastypie


【解决方案1】:

来自docs

默认的 Serializer 支持以下格式:

【讨论】:

  • 你知道我可以插入一个 html 序列化器吗?
  • 为什么要用html作为序列化器?
  • 好问题!我刚刚接管了这段代码,所以我不确定。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2019-05-12
  • 2021-12-18
  • 2013-03-10
  • 1970-01-01
  • 2015-08-10
  • 2020-04-12
  • 1970-01-01
相关资源
最近更新 更多