@step(STEP_PREFIX + r'<STR_LIT>'<EOL>+ r'<STR_LIT>')<EOL>def _create_m2m_links_step(self, rel_model_name,<EOL>rel_key, rel_value, relation_name):
lookup = {rel_key: rel_value}<EOL>rel_model = get_model(rel_model_name).objects.get(**lookup)<EOL>relation = None<EOL>for m2m in rel_model._meta.many_to_many:<EOL><INDENT>if relation_name in (m2m.name, m2m.verbose_name):<EOL><INDENT>relation = getattr(rel_model, m2m.name)<EOL>break<EOL><DEDENT><DEDENT>if not relation:<EOL><INDENT>try:<EOL><INDENT>relation = getattr(rel_model, relation_name)<EOL><DEDENT>except AttributeError:<EOL><INDENT>pass<EOL><DEDENT><DEDENT>assert relation,"<STR_LIT>" % (<EOL>rel_model._meta.verbose_name.capitalize(),<EOL>relation_name,<EOL>)<EOL>m2m_model = relation.model<EOL>for hash_ in self.hashes:<EOL><INDENT>relation.add(m2m_model.objects.get(**hash_))<EOL><DEDENT>
Link many-to-many models together.

Syntax:

    And `model` with `field` "`value`" is linked to `other model` in the
    database:

Example:

.. code-block:: gherkin

    And article with name "Guidelines" is linked to tags in the database:
        | name   |
        | coding |
        | style  |