Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation Error in Tutorial 4 #2303

Closed
epicserve opened this issue Dec 17, 2014 · 7 comments
Closed

Documentation Error in Tutorial 4 #2303

epicserve opened this issue Dec 17, 2014 · 7 comments

Comments

@epicserve
Copy link
Contributor

In the Tutorial 4: Authentication & Permissions documentation under "Associating Snippets with Users" it says to add the following method to the SnippetList view class.

def perform_create(self, serializer):
    serializer.save(owner=self.request.user)

However when trying to create a snippet you get this error.

Request Method: POST
Request URL:    http://127.0.0.1:8000/snippets/
Django Version: 1.7.1
Exception Type: AssertionError
Exception Value:    
The `.create()` method does not support writable dotted-source fields by default.
Write an explicit `.create()` method for serializer `snippets.serializers.SnippetSerializer`, or set `read_only=True` on dotted-source serializer fields.
@epicserve
Copy link
Contributor Author

FYI, adding the following method to SnippetSerializer was the fix for me.

def create(self, validated_data):
        return Snippet.objects.create(**validated_data)

@tomchristie
Copy link
Member

Yup. Resolved in master. #2263 and #2266.

@epicserve
Copy link
Contributor Author

@tomchristie I'm not sure why you closed this. I'm not seeing anything in the turtorial about adding that method. It should probably go in this section, https://github.com/tomchristie/django-rest-framework/blob/master/docs/tutorial/4-authentication-and-permissions.md#updating-our-serializer

@tomchristie
Copy link
Member

@epicserve On master (and the incoming 3.0.2 release) this will no longer be incorrectly identified as an error state.

@epicserve
Copy link
Contributor Author

I guess that's what's a little frustrating. The docs say to pip install djangorestframework which installs 3.0.1. Following the tutorial as it is right now doesn't work. Perhaps switching to something like Sphinx and Read The Docs would help it so you can have docs that go with the version in the tutorial!

@tomchristie
Copy link
Member

Latest version now on PyPI.

@tomchristie
Copy link
Member

(And we'll get versioning in MkDocs too at some point no doubt) :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants