1 | | F.e. |
2 | | {{{#!python |
3 | | class MainModel(models.Model): |
4 | | pass |
5 | | |
6 | | class RelatedModel(models.Model): |
7 | | main = models.ForeignKey(MainModel) |
8 | | }}} |
9 | | |
10 | | {{{ManyToOneRel.name}}} should be {{{relatedmodel_set}}}, not {{{relatedmodel}}} |
11 | | |
12 | | {{{#!python |
13 | | >>> from testmodels.models import MainModel |
14 | | >>> fieldname = MainModel._meta.get_fields()[0].name |
15 | | >>> print getattr(MainModel, fieldname, None) |
16 | | None |
17 | | >>> print getattr(MainModel, fieldname + '_set', None) |
18 | | <django.db.models.fields.related_descriptors.ReverseManyToOneDescriptor object at 0x103dc1510>}}} |