wagtail: Latest code throws 'unexpected keyword argument parent_page' in django-modelcluster
OK I probably shouldn’t be using the bleeding edge code, but I need some of the 1.4 fixes and features for my project and it was working well before. I’m getting an error with the latest code ever since the commits on Jan 25th to add the new permissions policy. Every time I try to create a new page I get:
Traceback (most recent call last):
File "/Users/matt/Dev/MyProject/MyApp/lib/python3.4/site-packages/django/core/handlers/base.py", line 149, in get_response
response = self.process_exception_by_middleware(e, request)
File "/Users/matt/Dev/MyProject/MyApp/lib/python3.4/site-packages/django/core/handlers/base.py", line 147, in get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/Users/matt/Dev/MyProject/MyApp/lib/python3.4/site-packages/django/views/decorators/cache.py", line 43, in _cache_controlled
response = viewfunc(request, *args, **kw)
File "/Users/matt/Dev/MyProject/MyApp/lib/python3.4/site-packages/django/contrib/auth/decorators.py", line 23, in _wrapped_view
return view_func(request, *args, **kwargs)
File "/Users/matt/Dev/MyProject/MyApp/MyApp/wagtail/wagtailadmin/views/pages.py", line 169, in create
parent_page=parent_page)
File "/Users/matt/Dev/MyProject/MyApp/lib/python3.4/site-packages/modelcluster/forms.py", line 208, in __init__
super(ClusterForm, self).__init__(data, files, instance=instance, prefix=prefix, **kwargs)
TypeError: __init__() got an unexpected keyword argument 'parent_page'
The old code used to call validate_page_form(form, parent_page) but this has been deleted and replaced by form = form_class(request.POST, request.FILES, instance=page, parent_page=parent_page) along with the offending parent_page.
This looks like an accidental bug (possibly triggered by my page models?) but I don’t understand this part of the code well enough to know how to fix it. Any help appreciated, even if it’s “don’t use the latest code yet”.
Thanks!
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 15 (5 by maintainers)
Commits related to this issue
- Temporary fix for issue #2267 Change base_form_class for TabbedInterface https://github.com/torchbox/wagtail/issues/2267#issuecomment-198377909 — committed to mihow/wagtail by mihow 8 years ago
- Get EditHandler form class from model if not overridden Unless overridden by passing `base_form_class=CustomFormClass` to an EditHandler, the EditHandler now gets the base form class from the model. ... — committed to neon-jungle/wagtail by mx-moth 8 years ago
- Check form class from Page edit handler for correct type Forms for Page classes must subclass WagtailAdminPageForm. If they do not, an error will be thrown for invalid arguments when the Page editor ... — committed to neon-jungle/wagtail by mx-moth 8 years ago
- Get EditHandler form class from model if not overridden Unless overridden by passing `base_form_class=CustomFormClass` to an EditHandler, the EditHandler now gets the base form class from the model. ... — committed to neon-jungle/wagtail by mx-moth 8 years ago
- Check form class from Page edit handler for correct type Forms for Page classes must subclass WagtailAdminPageForm. If they do not, an error will be thrown for invalid arguments when the Page editor ... — committed to neon-jungle/wagtail by mx-moth 8 years ago
- Get EditHandler form class from model if not overridden Unless overridden by passing `base_form_class=CustomFormClass` to an EditHandler, the EditHandler now gets the base form class from the model. ... — committed to neon-jungle/wagtail by mx-moth 8 years ago
- Check form class from Page edit handler for correct type Forms for Page classes must subclass WagtailAdminPageForm. If they do not, an error will be thrown for invalid arguments when the Page editor ... — committed to neon-jungle/wagtail by mx-moth 8 years ago
- Check form class from Page edit handler for correct type Forms for Page classes must subclass WagtailAdminPageForm. If they do not, an error will be thrown for invalid arguments when the Page editor ... — committed to wagtail/wagtail by mx-moth 8 years ago
- Get EditHandler form class from model if not overridden Unless overridden by passing `base_form_class=CustomFormClass` to an EditHandler, the EditHandler now gets the base form class from the model. ... — committed to wagtail/wagtail by mx-moth 8 years ago
- Check form class from Page edit handler for correct type Forms for Page classes must subclass WagtailAdminPageForm. If they do not, an error will be thrown for invalid arguments when the Page editor ... — committed to wagtail/wagtail by mx-moth 8 years ago
- Get EditHandler form class from model if not overridden Unless overridden by passing `base_form_class=CustomFormClass` to an EditHandler, the EditHandler now gets the base form class from the model. ... — committed to springload/wagtail by mx-moth 8 years ago
- Check form class from Page edit handler for correct type Forms for Page classes must subclass WagtailAdminPageForm. If they do not, an error will be thrown for invalid arguments when the Page editor ... — committed to springload/wagtail by mx-moth 8 years ago
Funny that we all encounter the same problem within minutes. I have the same problem.
I have a working fix, though:
-> Use this TabbedInterface instead of the shipped one.
@gasman: can you confirm that this is sufficient or do you see any side effects? AFAIK only the base_form_class must be adjusted.
@everyone: does this work for u as well?
@timheap thanks for this. @kaedroho, can you please review, with the aim of getting it in 1.4.2 in the next few days?
I’ve submitted a PR that should fix this issue. When adding a custom EditHandler to a Page class without setting a custom base_form_class for the EditHandler, the base_form_class is now taken from the model instead. This should make all previous custom EditHandlers work again.
I’ve also added a system check to ensure that form classes returned from Page EditHandlers subclass WagtailAdminPageForm, which should warn people when they make a custom EditHandler that would break the Page edit views.
Closing as unable to replicate.