Skip to content
This repository has been archived by the owner on Jan 20, 2022. It is now read-only.

KeyError: <pk> with duplicated 'name' #164

Open
wfehr opened this issue Jul 5, 2018 · 2 comments
Open

KeyError: <pk> with duplicated 'name' #164

wfehr opened this issue Jul 5, 2018 · 2 comments

Comments

@wfehr
Copy link

wfehr commented Jul 5, 2018

When you add your own "name" on fields and you have 2 fields with the same name, a internal server error (KeyError) occurs.
End of trace:

File "/usr/local/lib/python3.6/site-packages/cms/plugin_rendering.py", line 429, in render_plugin
context = plugin.render(context, instance, placeholder.slot)
File "/usr/local/lib/python3.6/site-packages/aldryn_forms/cms_plugins.py", line 385, in render
field_name = form_plugin.get_form_field_name(field=instance)
File "/usr/local/lib/python3.6/site-packages/aldryn_forms/models.py", line 289, in get_form_field_name
return self._form_field_key_cache[field.pk]

Problem:
in FieldPlugin.get_form_field_name() the function "get_form_fields_by_name()" gets called and returns a ordered dict with "(field.name, field)", where the duplicated fields are getting lost because the previous key-value-pair with the exact same "name" gets overwritten.

That said, is there a possible solution to prevent filling in duplicated "name"s for fields or maybe to just prevent a server error and print out something like "this field has a duplicated name, change it"?

@bartTC
Copy link

bartTC commented Mar 13, 2019

This happened to us out of the blue with copy/pasting a field into a form, where a field with the same name already existed.

There's no way for an editor to fix this, I had to slice this 'broken' plugin manually out of the db.

@oesah
Copy link

oesah commented Jul 14, 2019

Same issue here :( @bartTC How did you delete it manually?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants