I'm sorry for that trivial problem, but I'm still a bit lost...
#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')