Given the following model and serializer to configure Django REST :
#!/usr/bin/env python
...
#!/usr/bin/env python
Why do I get this AttributeError when I visit http://localhost:8000/stationreports/ ?
AttributeError at /stationreports/ 'StationReportSerializer' object has no attribute 'Meta' Request Method: GET Request URL: http://localhost:8000/stationreports/ Django Version: 1.7.3 Exception Type: AttributeError Exception Value: 'StationReportSerializer' object has no attribute 'Meta'
I followed the first part of a serializer tutorial that doesn't seem to work in the form presented. I already tried to remove the Meta class in the model, but still an error occurs.
Cause of the problem
For some reason, I definitely did not follow the mentioned Serializers tutorial. My above example works when I change the following:
Before:
class GaugeReportSerializer(serializers.HyperlinkedModelSerializer): water_level = serializers.IntegerField(required=True, max_length=5)
After
class GaugeReportSerializer(serializers.Serializer): water_level = serializers.IntegerField(required=True)
I think this error occurred because I used to be Quickstart .
python django django-rest-framework attributeerror
Jjd
source share