Invalid Literal for int() with base10 error

28 views
Skip to first unread message

Santhosh sridhar

unread,
Feb 11, 2020, 8:57:16 AM2/11/20
to Django users

I have a model called Project,

class Project(models.Model):
    name = models.CharField(max_length=50, unique=True)
    technology = models.ForeignKey(Technology, related_name='projects',on_delete=models.CASCADE)
    chipName = models.CharField(max_length=50)
    is_swarm = models.NullBooleanField(default=0, blank=True, null=True)
    p_state = models.ForeignKey(ProjectStage, related_name='projects', default=6,on_delete=models.CASCADE)
    project_poc = models.TextField()
    bto_date = models.DateField(blank=True, null=True)
    mto_date = models.DateField(blank=True, null=True)
    description = models.CharField(max_length=500, null=True)
    last_updated = models.DateTimeField(auto_now_add=True)


    def __str__(self):
        return self.name

    def save(self, *args, **kwargs):
        """
        Overriding base save method to set the default values for few fields based on user inputs.
        """

        if not self.mto_date:
            self.mto_date = self.bto_date + timedelta(days=15)

        super().save(*args, **kwargs)

In my views.py, I am trying to get Projects.objects.all() but I get this error : ValueError: invalid literal for int() with base 10: b'17 04:47:27.864928'

What could be the issue? I am using Django 2.2.1 and Python 3.6 versions.

Sunil H N

unread,
Feb 11, 2020, 11:56:30 AM2/11/20
to django...@googlegroups.com
Hi Santhosh,

The error is not coming in Projects.objects.all(). The error is occurring when you trying to convert some value to by int() but that value is not able to convert to int. Please check your logic once.

Regards,

Sunil H N
-sent from MacBook Air











On 11-Feb-2020, at 19:27, Santhosh sridhar <santhos...@gmail.com> wrote:

Projects.objects.all()

Reply all
Reply to author
Forward
0 new messages