#NEWLINE# def create_many_to_many_intermediary_model( field , klass ) : #NEWLINE# #INDENT# from django.db import models #NEWLINE# def set_managed( model , related , through ) : #NEWLINE# #INDENT# through . _meta . managed = ( model . _meta . managed or related . _meta . managed ) #NEWLINE# #UNINDENT# to_model = resolve_relation ( klass , field . remote_field . model ) #NEWLINE# name = ( '%s_%s' % ( klass . _meta . object_name , field . name ) ) #NEWLINE# lazy_related_operation ( set_managed , klass , to_model , name ) #NEWLINE# to = make_model_tuple ( to_model ) [ 1 ] #NEWLINE# from_ = klass . _meta . model_name #NEWLINE# if ( to == from_ ) : #NEWLINE# #INDENT# to = ( 'to_%s' % to ) #NEWLINE# from_ = ( 'from_%s' % from_ ) #NEWLINE# #UNINDENT# meta = type ( str ( 'Meta' ) , ( object , ) , { #NEWLINE# #INDENT# 'db_table' : field . _get_m2m_db_table ( klass . _meta ) , #NEWLINE# 'auto_created' : klass , #NEWLINE# 'app_label' : klass . _meta . app_label , #NEWLINE# 'db_tablespace' : klass . _meta . db_tablespace , #NEWLINE# 'unique_together' : ( from_ , to ) , #NEWLINE# 'verbose_name' : ( _ ( '%(from)s-%(to)s relationship' ) % { #NEWLINE# #INDENT# 'from' : from_ , #NEWLINE# 'to' : to , #NEWLINE# #UNINDENT# } ) , #NEWLINE# 'verbose_name_plural' : ( _ ( '%(from)s-%(to)s relationships' ) % { #NEWLINE# #INDENT# 'from' : from_ , #NEWLINE# 'to' : to , #NEWLINE# #UNINDENT# } ) , #NEWLINE# 'apps' : field . model . _meta . apps , #NEWLINE# #UNINDENT# } ) #NEWLINE# return type ( str ( name ) , ( models . Model , ) , { #NEWLINE# #INDENT# 'Meta' : meta , #NEWLINE# '__module__' : klass . __module__ , #NEWLINE# from_ : models . ForeignKey ( klass , related_name = ( '%s+' % name ) , db_tablespace = from_ . db_tablespace , db_constraint = field . remote_field . db_constraint , on_delete = CASCADE ) , #NEWLINE# to : models . ForeignKey ( to_model , related_name = ( '%s+' % name ) , db_tablespace = field . db_tablespace , db_constraint = field . remote_field . db_constraint , on_delete = CASCADE ) , #NEWLINE# #UNINDENT# } )