using 'pk' in fields throws KeyError

I've been following the tutorial step-by-step (using sqlite and
the same project structure, etc). I cannot for the life of me make 'pk'
be accepted as a valid field for Meta.fields of ModelSerializer...
'id' on the other hand seems to work very well.
This commit is contained in:
Pavel Savchenko 2012-10-30 22:00:01 +02:00
parent 166025c0fc
commit a33aa23484

View File

@ -201,7 +201,7 @@ Open the file `snippets/serializers.py` again, and edit the `SnippetSerializer`
class SnippetSerializer(serializers.ModelSerializer): class SnippetSerializer(serializers.ModelSerializer):
class Meta: class Meta:
model = Snippet model = Snippet
fields = ('pk', 'title', 'code', 'linenos', 'language', 'style') fields = ('id', 'title', 'code', 'linenos', 'language', 'style')