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

OPTIONS request fails for serializers.Serializer subclass #43

Open
adriaanwm opened this issue May 18, 2018 · 1 comment
Open

OPTIONS request fails for serializers.Serializer subclass #43

adriaanwm opened this issue May 18, 2018 · 1 comment

Comments

@adriaanwm
Copy link

adriaanwm commented May 18, 2018

example:

from rest_framework import serializers, generics
from django.urls import path


class ExampleSerializer(serializers.Serializer):
    field_one = serializers.CharField(required=True, write_only=True)
    field_two = serializers.CharField(required=True, write_only=True)

    def create(sef, validated_data):
        # do something
        return {}


class ExampleView(generics.CreateAPIView):
    serializer_class = ExampleSerializer


urlpatterns = [
    path('example', views.Example.as_view(), name='example'),
]

Making an OPTIONS request results in a 500 error: 'ExampleSerializer' has no attribute 'Meta'
Am I misunderstanding something, or is this a bug?

@adriaanwm
Copy link
Author

I ended up switching it to serializers.ModelSerializer and adding a Meta class as a temporary workaround.

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

1 participant