From: W. Trevor King Date: Mon, 2 Apr 2012 15:56:19 +0000 (-0400) Subject: Add related_names to ManyToManyFields for eventual backreferencing. X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=2ddfebaf20986def2094736a4579c20487d01cec;p=chemdb.git Add related_names to ManyToManyFields for eventual backreferencing. --- diff --git a/chemdb/models.py b/chemdb/models.py index 02c1e54..9aa4e9c 100644 --- a/chemdb/models.py +++ b/chemdb/models.py @@ -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()