Skip to content

Instantly share code, notes, and snippets.

class Foo(Model):
bars = ManyToManyField(Bar, related_name='foos', blank=True, null=True)
class Bar(Model):
name = CharField(unique=True)
# The process I know currently:
foo = Foo()
foo.save()
Traceback (most recent call last):
File "fail.py", line 10, in <module>
m_fail = MultipartEncoderMonitor.from_fields(fields=fields_fail)
File "/opt/active_version/lib/python2.7/site-packages/requests_toolbelt/multipart/encoder.py", line 297, in from_fields
encoder = MultipartEncoder(fields, boundary, encoding)
File "/opt/active_version/lib/python2.7/site-packages/requests_toolbelt/multipart/encoder.py", line 89, in __init__
self._prepare_parts()
File "/opt/active_version/lib/python2.7/site-packages/requests_toolbelt/multipart/encoder.py", line 171, in _prepare_parts
self.parts = [Part.from_field(f, enc) for f in fields]
File "/opt/active_version/lib/python2.7/site-packages/requests_toolbelt/multipart/encoder.py", line 383, in from_field