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

Type is incorrect if the lookup_field is set to be a one-2-one relation #481

Open
lingster opened this issue Oct 27, 2019 · 0 comments
Open

Comments

@lingster
Copy link

lingster commented Oct 27, 2019

Create say a UserProfile class which has a One2One relation to the User class, where the id is an integer.

class UserProfile():
    user = models.OneToOneField(User, on_delete=models.CASCADE, primary_key=True)

If you define the view set with lookup_field='user_id' then the generated swagger doc defaults the lookup_field as a string instead of integer
class UserProfileViewSet(viewsets.GenericViewSet):
queryset = UserProfile.objects.all()
serializer_class = UserProfileSerializer
lookup_field = 'user_id'

I'm currently working on a PR for this: #482

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