Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Move common functionality to destination base class #936
base: master
Are you sure you want to change the base?
Move common functionality to destination base class #936
Changes from all commits
4bca88d
026b181
20a9b30
7e5d4bb
23ea226
5b4fa46
2a33a31
a46cf8a
1fc078a
1d5d618
26b3b64
17ab4e4
7978355
baa2bb7
cfb9d3e
101c738
3155296
e07c3d2
305a23d
8ea2488
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This messes things up for me since the data I pass in (self.cleaned_data) includes an actual
Media
object, and not just the slugThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're supposed to pass in the raw stuff. I'll finish moving the error handling then I'll take a look.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How can I associate each error with the field that gave the error when its raised like this? I would kinda like to get the form object even though it contains errors so I can show it with errors included
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If these checks are moved to the
DestinationConfigForm.clean
(I think) they will be converted into errors inform.errors
. I'll do that.I'll show you some debugging techniques for forms.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
validate_settings
returns a dict (form.cleaned_data), but it looks like this assumes it returns the form itself?Got error here when trying to use this in HTMX version of destinations page:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I fix!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this raise keyerror if
settings
does not exist? Or wouldsettings = data.get("settings")
be better?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the key is not set or empty,
validate_settings
has been used wrong. The serializer skipsvalidate()
, and feeds the entire JSON tovalidate_settings
directly. It doesn't have to do that though!I don't have anything that uses
validate()
yet so now we are in Design Decision Needed territory. What do you think would be best?We could remove the settings-lookup entirely, and change the serializer to feed just the contents of "settings" to
validate_settings
. Then on the html-side we could have multiple Django forms in a single HTML<form>
and feed the request.POST querydict directly tovalidate_settings
.