Ticket #12245: 12245.m2m_intermediary_app_label.diff

File 12245.m2m_intermediary_app_label.diff, 1.2 KB (added by Johannes Dollinger, 15 years ago)
  • django/db/models/fields/related.py

     
    835835        'db_table': field._get_m2m_db_table(klass._meta),
    836836        'managed': managed,
    837837        'auto_created': klass,
     838        'app_label': klass._meta.app_label,
    838839        'unique_together': (from_, to)
    839840    })
    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 parts
    843     # of the namespace until we find .models
    844     parts = klass.__module__.split('.')
    845     while parts[-1] != 'models':
    846         parts.pop()
    847     module = '.'.join(parts)
    848841    # Construct and return the new class.
    849842    return type(name, (models.Model,), {
    850843        'Meta': meta,
    851         '__module__': module,
     844        '__module__': klass.__module__,
    852845        from_: models.ForeignKey(klass, related_name='%s+' % name),
    853846        to: models.ForeignKey(to_model, related_name='%s+' % name)
    854847    })
Back to Top