Skip to content

rework Field.__init__ to use either kwargs / class attrs.#2469

Closed
dnozay wants to merge 1 commit intoencode:masterfrom
dnozay:patch-2
Closed

rework Field.__init__ to use either kwargs / class attrs.#2469
dnozay wants to merge 1 commit intoencode:masterfrom
dnozay:patch-2

Conversation

@dnozay
Copy link

@dnozay dnozay commented Jan 26, 2015

Precedence is given to kwargs over class attributes.
You can create a subclass of a Field for 99% of your use cases while still
needing a one-off instance where you need to change an attribute; hence
kwargs is still useful.

Other important point is that kwargs is the current de-facto standard for
declaring fields in a serializer.

Conflicts:
rest_framework/fields.py

Precedence is given to kwargs over class attributes.
You can create a subclass of a Field for 99% of your use cases while still
needing a one-off instance where you need to change an attribute; hence
kwargs is still useful.

Other important point is that kwargs is the current de-facto standard for
declaring fields in a serializer.

Conflicts:
	rest_framework/fields.py
@lovelydinosaur
Copy link
Contributor

Main objection to this approach would be that we'd lose exceptions when a developer misspells an argument or otherwise includes an invalid keyword argument to a field.

@lovelydinosaur
Copy link
Contributor

Let's drop this one given that it would lose exceptions on misspelt arguments, which'd make it easier to introduce trivial errors.

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