Skip to content
This repository was archived by the owner on Apr 24, 2025. It is now read-only.

Conversation

@asiebert
Copy link

@asiebert asiebert commented Aug 31, 2017

Pretty sure this is caused by MongoEngine/mongoengine#1129: in that PR, verbose_name is no longer an actual attribute of fields classes. I guess this issue has something to with this document wrapper, scouring fields and trying to ensure the presence of verbose_name on them:

if not hasattr(f, 'verbose_name') or f.verbose_name is None:
f.verbose_name = capfirst(create_verbose_name(f.name))

When the form generators encounters a list field though, it tries to grab data from its field.field:
form_field = self.generate(field.field)

Sub-field that seems to be ignored by the wrapper, and thus does not have the optional verbose_name. If the list's field is declared explicitly with a verbose_name, the issue does not occur.

→ It seems acceptable for help_text to be undefined, so I'm doing the same for verbose_name.

@asiebert asiebert force-pushed the as/BAT-7558/MongoFormsBrokenListFields branch from f91f18a to 0a383f2 Compare August 31, 2017 02:35
@asiebert asiebert requested a review from m-vdb August 31, 2017 03:35

def get_field_label(self, field):
if field.verbose_name:
if hasattr(field, 'verbose_name') and field.verbose_name:
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if getattr(field, 'verbose_name', None):

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wouldn't say that's strictly equivalent – the current condition will fail if field.verbose_name is an empty string

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is, and if you want to nitpick use getattr(field, 'verbose_name', '')

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nevermind, you're correct 1dc7522

@m-vdb m-vdb merged commit c53be72 into master Sep 13, 2017
@m-vdb m-vdb deleted the as/BAT-7558/MongoFormsBrokenListFields branch September 13, 2017 15:49
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants