Skip to content

Conversation

@sevdog
Copy link
Contributor

@sevdog sevdog commented Jun 24, 2022

Description

As explained in #8527 this PR will provide the ability to choose the output format for DurationFields.

Since Python builtim timedelta object does not have any format function we are going to allow only formats which are already defined in Django codebase in the package django.utils.duration:

  • duration_string
  • duration_iso_string

@lovelydinosaur
Copy link
Contributor

Thanks - good to talk this through from a docs-first perspective.

@stale
Copy link

stale bot commented Oct 16, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Oct 16, 2022
@stale stale bot closed this Nov 1, 2022
@pietzschke
Copy link

Can we reopen this?

@auvipy auvipy reopened this Jun 4, 2024
@stale stale bot removed the stale label Jun 4, 2024
@pietzschke
Copy link

I think it's not possible to contribute to the pr to solve the conflicts, @sevdog would you be able to do it?
Otherwise i will create a new one and do the fixes.

@sevdog sevdog force-pushed the duration-format branch from 9d506ba to 9713c1d Compare June 5, 2024 09:28
@sevdog
Copy link
Contributor Author

sevdog commented Jun 5, 2024

Just rebased the PR, the "conflict" was a very silly issue in the doc file 🤷‍♂️

CI is failing due to a change in django-main branch, it should be addressed in an other PR.

@sevdog sevdog marked this pull request as ready for review June 5, 2024 09:33
@sevdog sevdog force-pushed the duration-format branch 2 times, most recently from 295a462 to 70751a5 Compare July 8, 2024 12:41
auvipy
auvipy previously requested changes Jul 9, 2024
Copy link
Collaborator

@auvipy auvipy left a comment

Choose a reason for hiding this comment

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

I saw FAILED tests/test_fields.py::TestISOOutputFormatDurationField::test_outputs
=========== 1 failed,

@sevdog sevdog force-pushed the duration-format branch from 70751a5 to 35398b3 Compare July 9, 2024 16:36
@sevdog
Copy link
Contributor Author

sevdog commented Jul 9, 2024

Ok, fixed the test. It was a long lasting double typo (wrong class and wrong format).

@auvipy auvipy requested a review from a team July 10, 2024 09:24
peterthomassen
peterthomassen previously approved these changes Jul 10, 2024
@sevdog sevdog force-pushed the duration-format branch from 35398b3 to bcc4ebf Compare July 11, 2024 06:13
@auvipy
Copy link
Collaborator

auvipy commented Jul 11, 2024

we should merge this only in a major release

@stale
Copy link

stale bot commented Apr 26, 2025

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Apr 26, 2025
@ulgens
Copy link
Contributor

ulgens commented Apr 27, 2025

The fix seems still relevant.

@auvipy auvipy removed the stale label Apr 27, 2025
Copy link
Collaborator

@auvipy auvipy left a comment

Choose a reason for hiding this comment

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

I'm not sure if this will be accepted or not, but if it is accepted, fixing the merge conflict should be enough

@sevdog
Copy link
Contributor Author

sevdog commented Apr 28, 2025

Conflict revolved.

Copy link
Collaborator

@peterthomassen peterthomassen left a comment

Choose a reason for hiding this comment

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

Thanks for resolving the conflict; some more comments here!

auvipy and others added 2 commits April 29, 2025 12:28
@stale
Copy link

stale bot commented Jul 19, 2025

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Jul 19, 2025
@pietzschke
Copy link

Can we have stale flag removed? We still need this @auvipy

@stale stale bot removed the stale label Jul 21, 2025
@sevdog
Copy link
Contributor Author

sevdog commented Jul 22, 2025

I am still waiting to get a response in this thread.

I was also thinking of re-creating the branch and the PR to have less noise and a cleaner git history.

@sevdog
Copy link
Contributor Author

sevdog commented Aug 7, 2025

I have updated the code and docs according to latest comments.

The validation check for format is performed in both __init__ and to_representation methods because it may be altered by the user during the lifecycle of the field or the initial config could be wrong. I have not put a check also in the settings item just to not have the same logic in 3 different points (2 are more than enough and those are already safe), it could be added with a minimal effor to raise also an ImproperlyConfigured.

Copy link
Collaborator

@peterthomassen peterthomassen left a comment

Choose a reason for hiding this comment

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

sorry, overlooked something.

Copy link
Collaborator

@peterthomassen peterthomassen left a comment

Choose a reason for hiding this comment

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

almost! 🙃

Copy link
Collaborator

@peterthomassen peterthomassen left a comment

Choose a reason for hiding this comment

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

lgtm!

@browniebroke browniebroke added this to the 3.17 milestone Aug 8, 2025
Copy link
Collaborator

@browniebroke browniebroke left a comment

Choose a reason for hiding this comment

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

Let's keep it as is

@peterthomassen peterthomassen merged commit c8b6d3d into encode:master Aug 12, 2025
7 checks passed
@auvipy
Copy link
Collaborator

auvipy commented Aug 12, 2025

thanks for the patience!

@browniebroke browniebroke changed the title DurationField output format Add ability to specify output format for DurationField Oct 29, 2025
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.

7 participants