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

No proper way to create customizable ModelResource #1034

Closed
andreynovikov opened this issue Nov 20, 2019 · 4 comments
Closed

No proper way to create customizable ModelResource #1034

andreynovikov opened this issue Nov 20, 2019 · 4 comments

Comments

@andreynovikov
Copy link
Contributor

I needed to customize my ModelResource behavior for each import. The most straightforward way is to add extra field to ImportForm. But there is no way to access form data from ModelResource.

The first issue is that get_import_resource_kwargs knows nothing about import forms. Thanks it knows about request. So the first ugly hack was to recreate and re-validate my custom import form inside this method.

But the next issue is even worse: custom field value from ImportForm should be passed through ConfirmImportForm but the solution from documentation can not work. See:

initial = self.get_form_kwargs(form=form, **initial)

Fortunately there is currently a typo in this line, it obviously should be:

initial = self.get_form_kwargs(form=confirm_form, **initial)

This typo makes possible second ugly hack to access ImportForm data to initialize ConfirmImportForm. But when you will fix it there would be no way to do that.

I suggest this part of import workflow should be redesigned.

@stale
Copy link

stale bot commented May 18, 2020

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 Stale bot label May 18, 2020
@mgrdcm
Copy link
Contributor

mgrdcm commented May 18, 2020

@andreynovikov I think this might be solved now in 2.1.0 by #994 and #1108. Can you confirm?

@imomaliev
Copy link

Should be fixed by #1185

@andrewgy8
Copy link
Member

This seems to be solved. I will close it for now.

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

No branches or pull requests

4 participants