V
V
Villian_Os2020-08-05 13:45:41
Django
Villian_Os, 2020-08-05 13:45:41

Why does django's object filter return invalid literal for int() with base 10: 'New'?

There is the following problematic line of code

list_reports = ReportInfo.objects.filter(status='Новый')

When calling a page with objects, where I pass list_reports to the template, it gives: ValueError at /new_reports/
invalid literal for int() with base 10: 'New'
Models:
class ReportStatus(models.Model):
    name = models.CharField(max_length=25)

    def __str__(self):
        return self.name

class ReportInfo(models.Model):
    name = models.CharField(max_length=80)
    status = models.ForeignKey(ReportStatus, null=True, on_delete=models.DO_NOTHING)


I don’t understand what’s the matter, I carried out migrations, deleted and installed the database again (sometimes it helped), rewrote the names of possible statuses, and still gives an error with such a filter.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dr. Bacon, 2020-08-05
@Villian_Os

Because you don't read the docsReportInfo.objects.filter(status__name='Новый')

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question