Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Closes #3937. Support callable as the value ofinitial for anyserializer.Field#3943

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation

@erickwilder
Copy link
Contributor

Please, refer to the#3937 for more information.

Add an usage example on how to pass a callable to the `Field.initial` in the docs.
@jpadilla
Copy link
Contributor

I think this is a great enhancement, thanks!

you may do with any regular Django`Field`:

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

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
ContributorAuthor

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
Contributor

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
ContributorAuthor

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` toillustrate the functionality.
@jpadilla
Copy link
Contributor

Looking good.@tomchristie any further comments?

@lovelydinosaur
Copy link
Contributor

👍 Yup!

@lovelydinosaur
Copy link
Contributor

@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
Contributor

@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
Contributor

@xordoquy ace, thanks!

jpadilla added a commit that referenced this pull requestFeb 19, 2016
…tial-valueCloses#3937. Support callable as the value of `initial` for any `serializer.Field`
@jpadillajpadilla merged commit0b6f53e intoencode:masterFeb 19, 2016
@jpadilla
Copy link
Contributor

@erickwilder thanks for this! 🎆

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Projects

None yet

Milestone

3.4.0 Release

Development

Successfully merging this pull request may close these issues.

4 participants

@erickwilder@jpadilla@lovelydinosaur@xordoquy

[8]ページ先頭

©2009-2025 Movatter.jp