1

Using Django 1.7.2 and djangorestframework==3.0.2

Getting error AttributeError: class Meta has no attribute 'model' for

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

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

although same code working for Django==1.8 and djangorestframework==3.2.3

Is this the issue with django or djangorestframework version ?

1
  • 1
    Pass model attribute in the class Meta: model=Notification as follows. Commented Sep 21, 2015 at 11:12

1 Answer 1

1

The issue is with your version of Django.

From the 1.8 changelog:


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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.