﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
34897	Django's admin UI - `ManyToManyField` with inheritance on the same class -> object shows itself inside the relation	Leon Haffmans	nobody	"Consider a base class `Followable` which is an actual table in the database. Create a `User` model, which inherits from `Followable` but also contains a `ManyToManyField` relating to `Followable` called `follows`.

Now, when using Django's admin panel, a user will (wrongly) always show up in `follows` as reference to itself. This reference has nothing to do with the database, there is no entry in the relation table.

This should serve as a little reproducable example:

{{{
class Followable(models.Model):
    # This is necessary to prevent doubled id name in `User`
    followable_id = models.BigAutoField(primary_key=True)

class User(Followable):
    alias = models.CharField(max_length=32)
    follows = models.ManyToManyField(Followable, blank=True, related_name=""followed_by"")

User(alias=""foo_user"").save()
user = User.objects.get(alias=""foo_user"")
assert len(user.follows) == 0
}}}

If this is a known issue, I apologize. I wasn't able to find posts addressing this issue."	Bug	closed	contrib.admin	4.2	Normal	invalid	inheritance, ManyToMany		Unreviewed	0	0	0	0	0	1
