lundi 4 décembre 2017

if statement in Django template issue

I am trying to compare value inside template of django. if statement is not working here is my code Model class:

class Run(models.Model):
    run_id = models.AutoField(primary_key=True)
    run_name = models.CharField(unique=True, max_length=30)
    pms_id = models.ForeignKey('ProcessManagementSystem', db_column = 'pms_id')

def __unicode__(self):
    return self.run_name 


class ProcessManagementSystem(models.Model):
    pms_id = models.AutoField(primary_key=True)
    pms_name = models.CharField(unique=True, max_length=30)

def __unicode__(self):
       return self.pms_name

My template



the interesting thing is when I am printing , it is not showing the ID, It is showing pms_name (maybe because of return self.pms_name)

So during compare, I am trying to compare with name i.e. "PMSName1" instead of id But still no luck. Any suggestion how to compare?

Thanks

Aucun commentaire:

Enregistrer un commentaire