Skip to content

make ObjectIdAutoField.to_python() accept integers as strings #175

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

Merged
merged 2 commits into from
Oct 29, 2024

Conversation

timgraham
Copy link
Collaborator

@timgraham timgraham commented Oct 25, 2024

There are at least two places in Django where Field.to_python() processes uncoerced form data, BaseModelFormSet._construct_form() and ModelAdmin.get_object().

@timgraham timgraham force-pushed the autofield-to-python branch from b524c2f to 8bb17ee Compare October 28, 2024 14:19
@timgraham timgraham requested a review from WaVEV October 28, 2024 14:24
@Jibola
Copy link
Contributor

Jibola commented Oct 29, 2024

Hrm, why should this silently accept an int conversion on the autofield? I understand that uncoerced data comes through the form construction, but wouldn't this be breaking assumptions on ObjectId types?

@timgraham
Copy link
Collaborator Author

This is a continuation of #105 (comment).

@Jibola
Copy link
Contributor

Jibola commented Oct 29, 2024

Ahhhh, thanks for the reminder.

Now that it's called "ObjectIdAutoField" rather than "MongoAutoField" I imagine this could lead to some confusion. Nonetheless, let's add the change in, but could you add a comment above including this ticket? https://jira.mongodb.org/browse/INTPYTHON-393

I don't think it's an issue now, nor is this a bad solution. I would want to revisit the semantics of this at a later date.

Copy link
Contributor

@Jibola Jibola left a comment

Choose a reason for hiding this comment

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

LGTM

@timgraham timgraham merged commit f35b419 into mongodb:main Oct 29, 2024
3 checks passed
@timgraham timgraham deleted the autofield-to-python branch October 29, 2024 14:30
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