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

'ManyToOneRel' object has no attribute 'help_text' when translating FormPage #284

Closed
itekhi opened this issue Dec 14, 2020 · 3 comments · Fixed by #620
Closed

'ManyToOneRel' object has no attribute 'help_text' when translating FormPage #284

itekhi opened this issue Dec 14, 2020 · 3 comments · Fixed by #620
Assignees

Comments

@itekhi
Copy link

itekhi commented Dec 14, 2020

The issue, don't know what else to say 😄:

Traceback (most recent call last):
  File "C:\Users\Shaffle\.virtualenvs\Qp0hboiu\lib\site-packages\django\core\handlers\exception.py", line 47, in inner
    response = get_response(request)
  File "C:\Users\Shaffle\.virtualenvs\Qp0hboiu\lib\site-packages\django\core\handlers\base.py", line 179, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "C:\Users\Shaffle\.virtualenvs\Qp0hboiu\lib\site-packages\django\views\decorators\cache.py", line 44, in _wrapped_view_func
    response = view_func(request, *args, **kwargs)
  File "C:\Users\Shaffle\.virtualenvs\Qp0hboiu\lib\site-packages\wagtail\admin\urls\__init__.py", line 127, in wrapper
    return view_func(request, *args, **kwargs)
  File "C:\Users\Shaffle\.virtualenvs\Qp0hboiu\lib\site-packages\wagtail\admin\auth.py", line 172, in decorated_view
    response = view_func(request, *args, **kwargs)
  File "C:\Users\Shaffle\.virtualenvs\Qp0hboiu\lib\site-packages\django\views\generic\base.py", line 70, in view
    return self.dispatch(request, *args, **kwargs)
  File "C:\Users\Shaffle\.virtualenvs\Qp0hboiu\lib\site-packages\wagtail\admin\views\pages\edit.py", line 114, in dispatch
    response = self.run_hook('before_edit_page', self.request, self.page)
  File "C:\Users\Shaffle\.virtualenvs\Qp0hboiu\lib\site-packages\wagtail\admin\views\generic.py", line 60, in run_hook
    result = fn(*args, **kwargs)
  File "C:\Users\Shaffle\.virtualenvs\Qp0hboiu\lib\site-packages\wagtail_localize\wagtail_hooks.py", line 144, in before_edit_page
    return edit_translation.edit_translation(request, translation, page)
  File "C:\Users\Shaffle\.virtualenvs\Qp0hboiu\lib\site-packages\wagtail_localize\views\edit_translation.py", line 471, in edit_translation
    string_segment_data = [
  File "C:\Users\Shaffle\.virtualenvs\Qp0hboiu\lib\site-packages\wagtail_localize\views\edit_translation.py", line 477, in <listcomp>
    'location': get_segment_location_info(source_instance, tab_helper, segment.context.path),
  File "C:\Users\Shaffle\.virtualenvs\Qp0hboiu\lib\site-packages\wagtail_localize\views\edit_translation.py", line 329, in get_segment_location_info
    'fieldHelpText': child_field.help_text,

Exception Type: AttributeError at /admin/pages/57/edit/
Exception Value: 'ManyToOneRel' object has no attribute 'help_text'
@itekhi
Copy link
Author

itekhi commented Dec 14, 2020

Update:

I tried to replace this 'fieldHelpText': child_field.help_text, in wagtail_localize/views/edit_translation.py on line 329 with this child_field.help_text if hasattr(child_field, 'help_text') else None.
And then another error appeared:

  File "C:\Users\Shaffle\.virtualenvs\mistralvision-Qp0hboiu\lib\site-packages\wagtail_localize\views\edit_translation.py", line 330, in get_segment_location_info
    'subField': capfirst(child_field.verbose_name),

Did the same with this one
'subField': capfirst(child_field.verbose_name) if hasattr(child_field, 'verbose_name') else None, and it works.
I don't know if this is the right way to do it, so I won't make a PR 😞.

@alice-telescoop
Copy link

Got the same issue. I used your workaround but I do think a fix would be beneficial

@zerolab zerolab self-assigned this Aug 29, 2022
@zerolab
Copy link
Collaborator

zerolab commented Sep 1, 2022

Hey all, happy to review a pull request with the fix noted above

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 a pull request may close this issue.

3 participants