Friday, March 23, 2018

How to undisplay the field with empty value in django admin?

I am currently working on django. I created 4 classes in models.py, one of them is ReactionMeta class. This class has 62 columns, which defined as below:

class Reactionsmeta(models.Model):    id = models.ForeignKey('Reactions', db_column='id', primary_key=True, max_length=255, on_delete=models.CASCADE)  name = models.CharField(max_length=255, blank=True, null=True)  metabolite1 = models.ForeignKey('Metabolites', db_column='metabolite1', blank=True, null=True,                                  on_delete=models.CASCADE)  stoichiometry1 = models.CharField(max_length=255, blank=True, null=True)  metabolite2 = models.ForeignKey('Metabolites', db_column='metabolite2', blank=True, null=True,                                  on_delete=models.CASCADE, related_name='+')  stoichiometry2 = models.CharField(max_length=255, blank=True, null=True)  metabolite3 = models.ForeignKey('Metabolites', db_column='metabolite3', blank=True, null=True,                                 on_delete=models.CASCADE, related_name='+')  stoichiometry3 = models.CharField(max_length=255, blank=True, null=True)  metabolite4 = models.ForeignKey('Metabolites', db_column='metabolite4', blank=True, null=True,                                  on_delete=models.CASCADE, related_name='+')  #...

Some of the reactions, may have 6 metabolites, like 2a + b + c -> 3d + e + f

however, some of reactions may only have 2 metabolites and stoichiometries, like a -> 2c

which means there is no value of this reaction in metabolite3,4,5,6...columns and stoichiometry 3,4,5,6...columns.

In that case, how can I only display the Charfield with data while undisplay those Charfield with no value in django-admin?

--
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/94300124-798c-43cb-aeaf-ec49d7ef141f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment