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

fix(utils): raise exception on failing creation of object #1398

Merged
merged 1 commit into from
Nov 18, 2024

Conversation

b1rger
Copy link
Contributor

@b1rger b1rger commented Nov 15, 2024

No description provided.

@gythaogg
Copy link
Contributor

Tested, works! Definitely prefer this implementation Could not create <field name> from <input value> to the previous error - None type object has no attribute pk.

This error message is of course valid when an actual error occurs while trying to create an object from a URI (assuming we have an importer defined)

But in this case when a user enters a non URI string or if the field is not setup to create objects from external sources - as I guess is the case with Profession in Discworld, could we maybe also inform that it is not possible to create new values from any string and it is currently only possible from URIs, if that is supported? Or in the case that there is no importer defined, could we disable the Create option?

@b1rger
Copy link
Contributor Author

b1rger commented Nov 15, 2024

But in this case when a user enters a non URI string or if the field is not setup to create objects from external sources - as I guess is the case with Profession in Discworld, could we maybe also inform that it is not possible to create new values from any string and it is currently only possible from URIs, if that is supported? Or in the case that there is no importer defined, could we disable the Create option?

Hm, currently the GenericImporter is a fallback for the case when no Importer is defined for a model, which means there is always in Importer defined. I'd say the Exception message is generic enough to be true for any case (be it a URL that could not be parsed or a non-url string) and we should probably look into ways to enable creating model instances from strings.

@b1rger b1rger merged commit d93a17d into main Nov 18, 2024
13 checks passed
@b1rger b1rger deleted the birger/1397-raise-on-failing-object branch November 18, 2024 07:12
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