Skip to content

Fix #4198 #4199

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

Closed
wants to merge 2 commits into from
Closed

Fix #4198 #4199

wants to merge 2 commits into from

Conversation

gcbirzan
Copy link
Contributor

Fixed #4198 by changing the following

  • Raise exception if field is defined on the class and present in extra_kwargs or read_only_fields
  • Do not overwrite options specified in extra_kwargs in get_uniqueness_extra_kwargs

- Raise exception if field is defined on the class and present in extra_kwargs or read_only_fields
- Do not overwrite options specified in extra_kwargs in get_uniqueness_extra_kwargs
read_only_fields = ('char_field', 'non_model_field')
fields = read_only_fields
read_only_fields = ('char_field',)
fields = read_only_fields + ('non_model_field', )
Copy link
Member

@kevin-brown kevin-brown Jun 15, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this make a test or two fail because non_model_field isn't actually defined as read-only anymore?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That particular test is TestMetaInheritance which doesn't try to set the
field, just checks whether it's set as read only. While the logic of the
test is not totally preserved, that's because the functionality changed.

On Wed, Jun 15, 2016 at 5:35 PM, Kevin Brown notifications@github.com
wrote:

In tests/test_model_serializer.py
#4199 (comment)
:

@@ -933,8 +933,8 @@ class TestSerializer(serializers.ModelSerializer):

         class Meta:
             model = OneFieldModel
  •            read_only_fields = ('char_field', 'non_model_field')
    
  •            fields = read_only_fields
    
  •            read_only_fields = ('char_field',)
    
  •            fields = read_only_fields + ('non_model_field', )
    

Shouldn't this make a test or two fail because non_model_field isn't
actually specified as read-only anymore?


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/tomchristie/django-rest-framework/pull/4199/files/5dd336ec6ca80dbcabaa1be054ac5a7f2f6c2a7d#r67173621,
or mute the thread
https://github.com/notifications/unsubscribe/AAv3ZSrABzE7kkWUp_UjAk2VfX6UOQVjks5qMA2ogaJpZM4I2QWM
.

George-Cristian Bîrzan

@tomchristie
Copy link
Member

Can you give me an example, and what you think the correct behaviour should be?

I'm not 100% sure what the best behavior should be.

@tomchristie
Copy link
Member

Dropping this:

  • Raise exception if field is defined on the class and present in extra_kwargs or read_only_fields

Given the subclassing use-case.

Taking this on:

  • Do not overwrite options specified in extra_kwargs in get_uniqueness_extra_kwargs

in #4349

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

Successfully merging this pull request may close these issues.

4 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy