MultipleObjectsReturned: get() returned more than one Embed
See original GitHub issueWe are getting this quite a lot.
We have a Sentry report over here: https://beta.getsentry.com/share/group/34313638322e3833333433303131/
MultipleObjectsReturned: get() returned more than one Embed -- it returned 2!
File "django/core/handlers/base.py", line 137, in get_response
response = response.render()
File "django/template/response.py", line 103, in render
self.content = self.rendered_content
File "django/template/response.py", line 80, in rendered_content
content = template.render(context)
File "django/template/base.py", line 148, in render
return self._render(context)
File "django/template/base.py", line 142, in _render
return self.nodelist.render(context)
File "django/template/base.py", line 844, in render
bit = self.render_node(node, context)
File "django/template/base.py", line 858, in render_node
return node.render(context)
File "django/template/loader_tags.py", line 126, in render
return compiled_parent._render(context)
File "django/template/base.py", line 142, in _render
return self.nodelist.render(context)
File "django/template/base.py", line 844, in render
bit = self.render_node(node, context)
File "django/template/base.py", line 858, in render_node
return node.render(context)
File "django/template/loader_tags.py", line 65, in render
result = block.nodelist.render(context)
File "django/template/base.py", line 844, in render
bit = self.render_node(node, context)
File "django/template/base.py", line 858, in render_node
return node.render(context)
File "django/template/base.py", line 904, in render
return render_value_in_context(output, context)
File "django/template/base.py", line 881, in render_value_in_context
value = force_text(value)
File "django/utils/encoding.py", line 83, in force_text
s = six.text_type(s)
File "wagtail/wagtailcore/blocks/stream_block.py", line 311, in __str__
return self.stream_block.render(self)
File "wagtail/wagtailcore/blocks/base.py", line 216, in render
return self.render_basic(value)
File "wagtail/wagtailcore/blocks/stream_block.py", line 201, in render_basic
[(force_text(child), child.block_type) for child in value]
File "wagtail/wagtailcore/blocks/stream_block.py", line 201, in <listcomp>
[(force_text(child), child.block_type) for child in value]
File "django/utils/encoding.py", line 83, in force_text
s = six.text_type(s)
File "wagtail/wagtailcore/blocks/stream_block.py", line 251, in __str__
return self.block.render(self.value)
File "wagtail/wagtailcore/blocks/base.py", line 216, in render
return self.render_basic(value)
File "wagtail/wagtailcore/blocks/base.py", line 223, in render_basic
return force_text(value)
File "django/utils/encoding.py", line 83, in force_text
s = six.text_type(s)
File "wagtail/wagtailembeds/blocks.py", line 21, in __str__
return embed_to_frontend_html(self.url)
File "wagtail/wagtailembeds/format.py", line 10, in embed_to_frontend_html
embed = embeds.get_embed(url)
File "wagtail/wagtailembeds/embeds.py", line 128, in get_embed
return Embed.objects.get(url=url, max_width=max_width)
File "django/db/models/manager.py", line 92, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "django/db/models/query.py", line 361, in get
num if num <= MAX_GET_RESULTS else 'more than %s' % MAX_GET_RESULTS
Issue Analytics
- State:
- Created 8 years ago
- Reactions:1
- Comments:8 (2 by maintainers)
Top Results From Across the Web
django - get() returned more than one topic - Stack Overflow
get() returns a single object. If there is no existing object to return, you will receive ...
Read more >get() returned more than one Question - YouTube
polls.models.Question. MultipleObjectsReturned : get() returned more than one Question -- it returned 2 in django , solved, get function in ...
Read more >get() returned more than one Patient -- it returned 7-django
I have a function for fetch API where I create a Django model object for each object in the JSON and store the...
Read more >GeoNode/general - Gitter
_meta.object_name, num) geonode.monitoring.models.MultipleObjectsReturned: get() returned more than one ServiceTypeMetric -- it returned 2! 2 replies.
Read more >7780 (get returns multiple objects when model includes a ...
Django throws a MultipleObjectsReturned error when getting a single instance of a model that includes a ManyToManyField in the default ordering.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I believe this is now fixed as of #6635 and #6815 - #6635 replaced the old unique_together constraint (with its unexpected treatment of null fields) with a unique constraint on the
hash
field (where that quirk doesn’t arise), and #6815 cleans up the duplicate records that were presumably created as a result of this bug.@lee-kagiso Thanks!
@kaedroho Argh, yes, you’re right - have just confirmed that Postgres will let me insert multiple records for the same URL with a null
max_width
. As far as I’m aware, the race condition protection inget_or_create
relies on the database enforcing this - very annoying. I guess the most sensible solution is to use something like -1 as a ‘magic number’ in place of null. (I suggest -1 rather than 0, as 0 might conceivably be a valid parameter - if you want an invisible audio embed, for example.)