You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm using mongodbforms for my Django application. I have a ListField of EmbeddedDocumentField and need to make a form out of it (Using embeddedformset_factory.). However the code won't run, returning the following error :
File "/home/jacques/.ve/ve_1/lib/python2.7/site-packages/mongodbforms/documents.py", line 919, in _get_embedded_field if (isinstance(field, EmbeddedDocumentField) and field.document_type == document) or \ UnboundLocalError: local variable 'field' referenced before assignment
So, after a very quick investigation, I found out the following piece of code inside mongodbforms/documents.py (line 917) :
emb_fields= [
fforfinparent_doc._fields.values()
if (isinstance(field, EmbeddedDocumentField) andfield.document_type==document) or \
(isinstance(field, ListField) andisinstance(field.field, EmbeddedDocumentField) andfield.field.document_type==document)
]
...Which seems quite incorrect to me, because field is never instantiated in the loop. Hence, I patched it this way, replacing field with f :
emb_fields= [
fforfinparent_doc._fields.values()
if (isinstance(f, EmbeddedDocumentField) andf.document_type==document) or \
(isinstance(f, ListField) andisinstance(f.field, EmbeddedDocumentField) andf.field.document_type==document)
]
Which now works properly. Is it possible to update the source ? (I'm not too familiar with Git so I don't want to make a mess of it.)
Have a nice day !
The text was updated successfully, but these errors were encountered:
Hi there.
I'm using mongodbforms for my Django application. I have a
ListField
ofEmbeddedDocumentField
and need to make a form out of it (Usingembeddedformset_factory
.). However the code won't run, returning the following error :File "/home/jacques/.ve/ve_1/lib/python2.7/site-packages/mongodbforms/documents.py", line 919, in _get_embedded_field if (isinstance(field, EmbeddedDocumentField) and field.document_type == document) or \ UnboundLocalError: local variable 'field' referenced before assignment
So, after a very quick investigation, I found out the following piece of code inside
mongodbforms/documents.py
(line 917) :...Which seems quite incorrect to me, because
field
is never instantiated in the loop. Hence, I patched it this way, replacingfield
withf
:Which now works properly. Is it possible to update the source ? (I'm not too familiar with Git so I don't want to make a mess of it.)
Have a nice day !
The text was updated successfully, but these errors were encountered: