Vinicius Vaghetti
Vinicius Vaghetti

Reputation: 7

Django __str__ returned non-string (type tuple), i didn't define __str__

I'm working on a duplicate reporting system on Django, and i created a table on my models.py that goes

class DupReport(models.Model):
count = models.IntegerField()
oldersub = models.ForeignKey('Submission', on_delete=models.CASCADE, related_name='older_sub')
newersub = models.ForeignKey('Submission', on_delete=models.CASCADE, related_name='newer_sub')

And when i go to admin to add a row, the menu that displays the rows works fine, but when i click add DupReport, i get this:

TypeError at /admin/apppickoff/dupreport/add/

str returned non-string (type tuple)

< a href="{% add_preserved_filters history_url %}" class="historylink">{% trans "History" %}< /a>

Upvotes: 0

Views: 1063

Answers (1)

Will Hardy
Will Hardy

Reputation: 14836

Look for a stray comma at the end of any __str__ definitions that you did write.

Returning a value with a comma at the end will turn your value into a tuple containing that value.

Upvotes: 1

Related Questions