Простая проблема. Что происходит, когда у вас есть имя «формат» как атрибут модели с TastyPie?Характеристики атрибута Django tastypie формата
Как вы обрабатываете запрос для http://0.0.0.0:9000/api/v1/library_type/?format=json?
, когда у вас есть модель, которая выглядит так.
class LibraryType(models.Model):
"""The information about each library type."""
format = models.IntegerField(choices=LIBRARYTYPE_CHOICES)
equiv = models.IntegerField()
name = models.CharField(max_length=96)
prefix = models.CharField(max_length=96)
description = models.CharField(max_length=255, db_column='remark')
Вы в конечном итоге с:
{
"error": "Invalid resource lookup data provided (mismatched type)."
}
Очевидно, что это имеет смысл, но как с ним работать? Соответствующее определение ресурса.
class LibraryTypeResource(ModelResource):
class Meta:
queryset = LibraryType.objects.all()
resource_name = 'library_type'
list_allowed_methods = ['get',]
detail_allowed_methods = ['get', ]
filtering = {
'id': ('exact',),
'name': ALL,
'format': ALL,
'prefix': ALL,
'description': ALL,
'site': ALL_WITH_RELATIONS,
}
Возможно, ваш 'format' является' IntegerField', и вы передаете 'format = json' - строку? –
Ну, если вы хотите сохранить фильтрацию по имени * format *, лучшим решением было бы изменить его имя, так как * format * key-name жестко закодирован, и, похоже, вам придется переопределить или обезвредить функцию 'define_format' изменить его .. – mariodev