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

Add support for passing extra parameters to the form constructor (FormPreview) #233

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Tobi-De
Copy link

@Tobi-De Tobi-De commented Mar 30, 2023

Hey there,

I'm writing to submit a pull request that improves the FormPreview view.

I ran into an issue when trying to pass extra context to the form constructor. While it's common to pass the request object to a form instance in Django, doing so with the FormPreview view required me to override several methods, including post_post, preview_post, and preview_get. This made the code more complex and harder to maintain.

To address this problem, I propose adding a form_extra_params(self, request) method that allows users to pass extra data to their form if needed. This method takes the request object as an argument, and by default, it returns an empty dictionary. Users can override this method to provide additional context to the form constructor, without having to modify the view's core methods.

I believe that this solution simplifies the code and makes it more flexible for developers who need to handle custom validation logic. I hope that you will find this pull request useful and that you will consider merging it into the main branch.

Thank you for your time and for maintaining this great package!

Best regards,
Tobi

PS: I'm not entirely sure how to write a test for this feature, but I believe it's straightforward enough that testing may not be necessary. However, if you feel that testing is required, I would be more than happy to conduct research and update my code accordingly. Thanks.

@Tobi-De Tobi-De requested a review from claudep March 30, 2023 15:45
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.

None yet

1 participant