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

Formsets are hard to override #1957

Closed
maikhoepfel opened this Issue Dec 30, 2015 · 3 comments

Comments

Projects
None yet
4 participants
@maikhoepfel
Member

maikhoepfel commented Dec 30, 2015

For instance, it's hard to override the dashboard's StockRecordForm. If one wants to add or remove a field, one has to inherit the field, but also copy across StockRecordFormSet.
Most likely, we want to move all of Oscar's formsets into formsets modules, and dynamically load the related forms.

@maxshilov

This comment has been minimized.

Show comment
Hide comment
@maxshilov

maxshilov Dec 31, 2015

hello Maik,

Could you please explain why get_class solution would't work in this case?

maxshilov commented Dec 31, 2015

hello Maik,

Could you please explain why get_class solution would't work in this case?

@Mohl

This comment has been minimized.

Show comment
Hide comment
@Mohl

Mohl Jan 8, 2016

Contributor

@maikhoepfel is right. I just added a field to StockRecord. To expose that field to the dashboard, one has to do the following:

Override the StockRecordForm (thats obvious)
Override the BaseStockRecordFormSet (it's not using get_class, because the two classes are in the same file)
copy the whole StockRecordFormSet to the own catalogue/forms.py (yes, hardcopy. this adds 64 lines to your project that you are now responsible for. You have to do this in order to point the class to your version of BaseStockRecordFormSet, which uses your StockRecordForm).
override the ProductCreateUpdateView and manually set it's formset dict to the StockRecordFormSet you just copied.
override the dashboard/catalogue/product_update.html template and manually add override the block stockrecords_content, which adds another 60 or so lines to your responsibility.

Aka, you have to spend 2 hours on a 15 Minute job.

Contributor

Mohl commented Jan 8, 2016

@maikhoepfel is right. I just added a field to StockRecord. To expose that field to the dashboard, one has to do the following:

Override the StockRecordForm (thats obvious)
Override the BaseStockRecordFormSet (it's not using get_class, because the two classes are in the same file)
copy the whole StockRecordFormSet to the own catalogue/forms.py (yes, hardcopy. this adds 64 lines to your project that you are now responsible for. You have to do this in order to point the class to your version of BaseStockRecordFormSet, which uses your StockRecordForm).
override the ProductCreateUpdateView and manually set it's formset dict to the StockRecordFormSet you just copied.
override the dashboard/catalogue/product_update.html template and manually add override the block stockrecords_content, which adds another 60 or so lines to your responsibility.

Aka, you have to spend 2 hours on a 15 Minute job.

@sasha0

This comment has been minimized.

Show comment
Hide comment
@sasha0

sasha0 Jan 19, 2016

Member

@maikhoepfel @mvantellingen how about backward compatibility?

Member

sasha0 commented Jan 19, 2016

@maikhoepfel @mvantellingen how about backward compatibility?

@sasha0 sasha0 closed this in #1975 Mar 31, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment