Many to many
Purpose: linking models by a relationship in which one record from each table can correspond to several records from another and vice versa.
Field type in SQL table: the field is not set in the model, but a linking table of 2 columns is created for the Id of each model.
Required parameters
related_model
Purpose: name of the model to which the current model is related
Possible values: model name, for example 'People', ‘ProductsBrands’
Additional parameters
name_field
Purpose: if the related model does not have a field called ‘name’, then you must explicitly specify the named field
Possible values: text, for example 'title'
Default: ‘name’
long_list
Purpose: used if the list of values is long, then the values are taken using the search string
Possible values: true, false
Default: false
['Videos', 'many_to_many', 'videos', ['related_model' => 'Videos']]
['Specializations', 'many_to_many', 'services', [
'related_model' => 'Services',
'long_list' => true]]
Previous section
Many to one