Add related_names to ManyToManyFields for eventual backreferencing.
authorW. Trevor King <wking@drexel.edu>
Mon, 2 Apr 2012 15:56:19 +0000 (11:56 -0400)
committerW. Trevor King <wking@drexel.edu>
Mon, 2 Apr 2012 15:56:19 +0000 (11:56 -0400)
chemdb/models.py

index 02c1e548805f178ee479a066111bbe1028e7c7b2..9aa4e9c5d11b08ebf3a50df5455b005436462871 100644 (file)
@@ -47,7 +47,8 @@ class Chemical (NamedItem):
     duplicate information (e.g. you can have two bottles of acetic
     acid).
     """
-    cas = _models.ManyToManyField(CASNumber, blank=True, null=True)
+    cas = _models.ManyToManyField(
+        CASNumber, blank=True, null=True, related_name='chemicals')
     msds = _models.FileField(
         'Material safety data sheet', upload_to=_util.chemical_upload_to,
         blank=True, null=True)
@@ -57,7 +58,8 @@ class Chemical (NamedItem):
         'NFPA fire rating', blank=True, null=True)
     reactivity = _models.PositiveIntegerField(
         'NFPA reactivity rating', blank=True, null=True)
-    special = _models.ManyToManyField(NFPASpecial, blank=True, null=True)
+    special = _models.ManyToManyField(
+        NFPASpecial, blank=True, null=True, related_name='chemicals')
     mutagen = _models.NullBooleanField()
     carcinogen = _models.NullBooleanField()
     teratogen = _models.NullBooleanField()