Ticket #12245: 12245.m2m_intermediary_app_label.diff
File 12245.m2m_intermediary_app_label.diff, 1.2 KB (added by , 15 years ago) |
---|
-
django/db/models/fields/related.py
835 835 'db_table': field._get_m2m_db_table(klass._meta), 836 836 'managed': managed, 837 837 'auto_created': klass, 838 'app_label': klass._meta.app_label, 838 839 'unique_together': (from_, to) 839 840 }) 840 # If the models have been split into subpackages, klass.__module__841 # will be the subpackge, not the models module for the app. (See #12168)842 # Compose the actual models module name by stripping the trailing parts843 # of the namespace until we find .models844 parts = klass.__module__.split('.')845 while parts[-1] != 'models':846 parts.pop()847 module = '.'.join(parts)848 841 # Construct and return the new class. 849 842 return type(name, (models.Model,), { 850 843 'Meta': meta, 851 '__module__': module,844 '__module__': klass.__module__, 852 845 from_: models.ForeignKey(klass, related_name='%s+' % name), 853 846 to: models.ForeignKey(to_model, related_name='%s+' % name) 854 847 })