Integrity problems when using get_or_create through M2M

As described on [#18896](https://code.djangoproject.com/ticket/18896), if we use `get_or_create` through M2M fields or reverse FK, we can have integrity problems. As there's no obvious solution over here, I'm adding a note into the documentation for it. I also added a couple of tests cases for checking that bug.