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

Closes #3937. Support callable as the value of initial for any serializer.Field #3943

Merged

Conversation

erickwilder
Copy link
Contributor

@erickwilder erickwilder commented Feb 17, 2016

Please, refer to the #3937 for more information.

erickwilder added 2 commits Feb 17, 2016
Add an usage example on how to pass a callable to the `Field.initial` in the docs.
@jpadilla
Copy link
Member

jpadilla commented Feb 17, 2016

I think this is a great enhancement, thanks!

you may do with any regular Django `Field`:

def user_default_color():
return 'blue'
Copy link
Member

@tomchristie tomchristie Feb 18, 2016

Choose a reason for hiding this comment

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

Let's have an example that makes a bit more sense.
I can only think of date/time examples - are there an other obvious use cases?

Copy link
Contributor Author

@erickwilder erickwilder Feb 18, 2016

Choose a reason for hiding this comment

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

I think the date/time example is fine. Other use cases are possible but I think they'll make it more difficult to the reader to understand. Also, the example from the official Django docs[1] uses date/time too.

[1] https://docs.djangoproject.com/en/1.9/ref/forms/fields/#initial

Copy link
Member

@tomchristie tomchristie Feb 18, 2016

Choose a reason for hiding this comment

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

Great - let's do the same! :)

Copy link
Contributor Author

@erickwilder erickwilder Feb 19, 2016

Choose a reason for hiding this comment

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

Hello @tomchristie
I've updated the docs. May you take a look?

Just like regular Django fields, the example adopted uses a `datetiume.date.today` to
illustrate the functionality.
@jpadilla
Copy link
Member

jpadilla commented Feb 19, 2016

Looking good. @tomchristie any further comments?

@tomchristie
Copy link
Member

tomchristie commented Feb 19, 2016

👍 Yup!

@tomchristie
Copy link
Member

tomchristie commented Feb 19, 2016

@xordoquy - I'm a bit unclear on branching plans - should we merge this to master and re-milestone as 3.3.0?

@xordoquy
Copy link
Collaborator

xordoquy commented Feb 19, 2016

@tomchristie will take some time tomorrow to add more information about branching.
Anything that goes into master will be for 3.4. I've opened a 3.3.x branch for the bug fixes only.

@jpadilla
Copy link
Member

jpadilla commented Feb 19, 2016

@xordoquy ace, thanks!

jpadilla added a commit that referenced this pull request Feb 19, 2016
…tial-value

Closes #3937. Support callable as the value of `initial` for any `serializer.Field`
@jpadilla jpadilla merged commit 0b6f53e into encode:master Feb 19, 2016
2 checks passed
@jpadilla
Copy link
Member

jpadilla commented Feb 19, 2016

@erickwilder thanks for this! 🎆

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.

None yet

4 participants