question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

get() returned more than one Tag -- it returned 2!

See original GitHub issue

Hello Sometimes when adding tags to an existing object, I am getting the following error.

get() returned more than one Tag -- it returned 2!

Here is the code I am using

...
publication.tags.set(all_tags, clear=True)
publication.save()
# I also tried
publication.tags.set(all_tags)
publication.save()
# and
publication.tags.add(*all_tags)
publication.save()
# but still getting the same issue
...

Notes:

  • I am not using any get function
  • Django version 4.1

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
rtpgcommented, Nov 26, 2022

@naskio thank you very much for that detail! It sounds very important.

If in your system you have that problem, the easiest thing to do would be to normalize manually in a database migration. So for example you find all of the TaggedItems that are pointing to UKRAINE and then point them to Ukraine. From there, you should be able to delete UKRAINE.

You’ll need to do some database cleanup. I think though that this error should have its own handling, though. And it might even make sense for us to write a helper management command… but at the very least we should document what to do.

0reactions
naskiocommented, Dec 2, 2022

@rtpg For me the ideal solution would be to have both options: 1- Handling this case by taking only the first tag when get() returns more than one, This would be more flexible enabling us to disable TAGGIT_CASE_INSENSITIVE again without impacting the data. 2- A management command if someone decides to enable TAGGIT_CASE_INSENSITIVE and keep only one instance of similar tags.

Read more comments on GitHub >

github_iconTop Results From Across the Web

django - get() returned more than one topic - Stack Overflow
get() returned more than one topic -- it returned 2! The above error indicatess that you have more than one record in the...
Read more >
get() returned more than one Answer -- it returned 2!
Saw one traceback where it looks like we do a .get() for a flow_id that returns two records. Needs investigation. Traceback: Internal Server...
Read more >
MultipleObjectsReturned: get() returned more than one ...
MultipleObjectsReturned: get() returned more than one EmailAddress -- it returned 2! Hi,. We've encountered the error in Postorius on ...
Read more >
get() returned more than one Post -- it returned 2! : r/django
i was trying to make like button for my blog but i'm getting that error get() returned more than one Post -- it...
Read more >
MultipleObjectsReturned: get() returned more than one Question
Now you may perform more filters like Model.objects.filter(fname=first_name).first() if you want only first.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found