﻿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
7215	related_name argument for ForeignKey ignored when inheriting from abstract base class	Joel Watts	Joel Watts	"When using a !ForeignKey with the related_name argument in an abstract base class, the reverse accessors for child models aren't created.

The problem can be reproduced using the following models:

{{{
import datetime

from django.db import models

class Post(models.Model):
    title = models.CharField(u'Title', max_length=50)

class Attachment(models.Model):
    post = models.ForeignKey(Post, related_name='attached_%(class)s_set')
    content = models.TextField(u'Content')

    class Meta:
        abstract = True

class Comment(Attachment):
    is_spam = models.BooleanField(u'Spam')

class Update(Attachment):
    timestamp = models.DateTimeField(default=datetime.datetime.now)

}}}

Given those models, I would expect `Post` to have two accessors for related models: `Post.attached_comment_set` and `Post.attached_update_set`, but it doesn't.  In their place is a single accessor named `Post.attached_%(class)s_set`.

I'm attaching a patch that rearranges `django.db.models.fields.related.RelatedField.contribute_to_class` enough to get the accessor methods, but I didn't see where the `attached_%(class)s_set` attribute was being created."		closed	Core (Other)	dev		fixed	qsrf-cleanup model inheritance related	joel@…	Ready for checkin	1	0	0	0	0	0
