﻿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
28563	Allow parent relations to specify the related_name of a class property	Samuel Spencer	tothegump	"I can't come up with an appropriate example, so I'll use a cut back version of actual code. I'm trying to implement an ISO standard, and am using a concrete base class, with a number of relations between objects, as shown below. Unfortunately, the names of these objects and relations are defined by the spec and can't be changed without a lot of hassle.
	
{{{
	
class Metadata(models.Model):
    name = models.CharField(max_length=255)
	
class Property(Metadata):
    pass
	
class ObjectClass(Metadata):
    pass
	
class DataElementConcept(Metadata):
    object_class = models.ForeignKey(ObjectClass)
    property= models.ForeignKey(Property)
	
}}}
	
However, the system checker has a problem with this:
	
{{{
SystemCheckError: System check identified some issues:
	
ERRORS:
aristotle_mdr.DataElementConcept.property: (models.E006) The field 'property' clashes with the field 'property' from model 'aristotle_mdr._concept'.
}}}
	
What appears to happen is that DataElementConcept.property (a relation between two pieces of metadata) is clashing with MetadataItem.property (a relation from parent class to child class).
	
Since a parent-child relationship using inheritance is just a OneToOneField thats made by [https://github.com/django/django/blob/5cc746206726c538c36a2830e7c068f1c8a0e7c8/django/db/models/base.py#L234 django.db.models.base.ModelBase] it'd be nice to be able to add some details to a classes Meta field to change the related_name of the generated field, for example:
	
{{{
	
class Metadata(models.Model):
    name = models.CharField(max_length=255)
	
class Property(Metadata):
    class Meta:
        parent_related_name = ""property_subclass""
	
}}}
	
and the ModelBase coude would be similar to:
	
{{{
                    field = OneToOneField(
                        base,
                        on_delete=CASCADE,
                        name=attr_name,
                        auto_created=True,
                        parent_link=True,
                        related_name=base._meta.parent_related_name
                    )
}}"	New feature	closed	Uncategorized	1.11	Normal	wontfix			Unreviewed	0	0	0	0	1	0
