Skip to content

Fix Tutorial5 serializers.py typo #1011

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

Merged
merged 1 commit into from
Jul 27, 2013
Merged

Fix Tutorial5 serializers.py typo #1011

merged 1 commit into from
Jul 27, 2013

Conversation

coderigo
Copy link
Contributor

A slight typo in Tutorial5's SnippetSerializer class's Meta class causing an exception "name 'models' is not defined". A subtle one that can confuse Python/Django newbies like me.

As far as I was able to follow and reproduce, at the end of Tutorial5 the serializers.py file should look like this:

from django.forms import widgets
from rest_framework import serializers
from snippets.models import Snippet, LANGUAGE_CHOICES, STYLE_CHOICES
from django.contrib.auth.models import User

class SnippetSerializer(serializers.HyperlinkedModelSerializer):
    owner     = serializers.Field(source='owner.username')
    highlight = serializers.HyperlinkedIdentityField(view_name='snippet-highlight', format='html')

    class Meta:
        model  = Snippet
        fields = ('url', 'highlight', 'owner','title', 'code', 'linenos', 'language', 'style')

class UserSerializer(serializers.HyperlinkedModelSerializer):
    snippets = serializers.HyperlinkedRelatedField(many=True, view_name='snippet-detail')

    class Meta:
        model  = User
        fields = ('url', 'username', 'snippets')

[Issue #N/A]

A slight typo at Tutorial5 causing an Exception "name 'models' is
not defined". A subtle one that can confuse Python/Django noobs
like me.
@minddust
Copy link
Contributor

yep thanks

minddust added a commit that referenced this pull request Jul 27, 2013
Fix Tutorial5 serializers.py typo
@minddust minddust merged commit f22efdc into encode:master Jul 27, 2013
@minddust
Copy link
Contributor

if you leave a name i will put you on the credits list

@coderigo
Copy link
Contributor Author

Thanks @minddust.
Rodrigo Martell

@coderigo coderigo deleted the docs branch July 27, 2013 23:41
minddust added a commit that referenced this pull request Jul 28, 2013
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

Successfully merging this pull request may close these issues.

2 participants