2015-09-21 4 views
1

Использование Django 1.7.2 и djangorestframework==3.0.2Джанго: AttributeError: класс Meta не имеет атрибута 'модель'

Получение ошибки AttributeError: class Meta has no attribute 'model' для

class NotificationCountSerializer(serializers.Serializer): 
    ------ 
    ------ 

    class Meta: 
     fields = ('drivers_count', 'vehicles_count', 'maps_count') 

хотя тот же код работает Django==1.8 и djangorestframework==3.2.3

Это вопрос с версией django или djangorestframework?

+1

Pass атрибут модели в классе Meta: модель = Уведомление следующим образом. –

ответ

1

Проблема с вашей версией Django.

Из 1.8 список изменений:


What’s new in Django 1.8

Model._meta API

Django now has a formalized API for Model._meta, providing an officially supported way to retrieve fields and filter fields based on their attributes.

The Model._meta object has been part of Django since the days of pre-0.96 “Magic Removal” – it just wasn’t an official, stable API. In recognition of this, we’ve endeavored to maintain backwards-compatibility with the old API endpoint where possible. However, API endpoints that aren’t part of the new official API have been deprecated and will eventually be removed. A guide to migrating from the old API to the new API has been provided

Смежные вопросы