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

Always defer to explicit overrides. #4198

Closed
tomchristie opened this issue Jun 14, 2016 · 2 comments
Closed

Always defer to explicit overrides. #4198

tomchristie opened this issue Jun 14, 2016 · 2 comments
Milestone

Comments

@tomchristie
Copy link
Member

tomchristie commented Jun 14, 2016

Some of these may already be covered, but we should make sure that all the following are satisfied:

  • If a user declares a field explicitly, but also includes it in extra_kwargs then warn/error.
  • If a user declares a field explicitly, but also includes it in read_only_fields then warn/error.
  • Don't allow get_uniqueness_extra_kwargs to override a declared field.
  • Don't allow get_uniqueness_extra_kwargs to override a flag that has been set in extra_kwargs.
  • If a serializer field has a default, then ensure that uniqueness validators use that for empty, rather than forcing required=True
@tomchristie tomchristie added this to the 3.4.0 Release milestone Jun 14, 2016
@gcbirzan
Copy link
Contributor

  • Don't allow get_uniqueness_extra_kwargs to override a declared field.

This already happens, a declared field will not be re-declared with new args.

  • If a serializer field has a default, then ensure that uniqueness validators use that for empty, rather than forcing required=True

A default of None on a declared field will work for uniqueness validation.

@tomchristie
Copy link
Member Author

Thanks for those confirmations @gcbirzan!

gcbirzan pushed a commit to gcbirzan/django-rest-framework that referenced this issue Jun 15, 2016
- 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
@gcbirzan gcbirzan mentioned this issue Jun 15, 2016
gcbirzan pushed a commit to gcbirzan/django-rest-framework that referenced this issue Jun 15, 2016
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