Monday, April 13, 2015

Re: classic: unsupported operand type(s) for +: 'int' and 'NoneType'

It's  ram_tot = self.ram_1 + self.ram_2

that returns me "cannot contenate int and NOne

On Monday, April 13, 2015 at 10:05:49 PM UTC+2, makayabou wrote:
Hello,
I'm sorry for that trivial problem, but I'm still a bit lost...

[code]
#In models.py:

class Ordi(models.Model):
RAM_CAP_1 = 1024
RAM_CAP_2 = 2048
RAM_CAP_CHOICES = (
(RAM_CAP_1, u'1G'),
(RAM_CAP_2, u'2G'),
)
ram_1 = models.IntegerField("memory slot 1", max_length=10, choices=RAM_CAP_CHOICES, null= True, blank=True)
ram_2 = models.IntegerField("memory slot 2", max_length=10, choices=RAM_CAP_CHOICES, null= True, blank=True)

def ram_total(self):
ram_tot = self.ram_capacite_1 + self.ram_capacite_2
#
# Here, python can't contenate int and NoneType...
#
return ram_tot
def maintenus(self):
ordis_maintenus = self.maintenance_set.all()
for o in ordis_maintenus:
return o.__unicode__
    def __unicode__(self):
        return 'ordi '+unicode(self.id)+' - '+self.renvoios()


class Maintenance(models.Model):
    ordi = models.ForeignKey(Ordi)
    def __unicode__(self):
        return self.titre + " du " +self.date_sortie.strftime('%m/%d/%Y')
        
[/code]

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/f30ef94f-55b4-482f-9b39-a007e99321ff%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment