﻿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
529	Add support for GenericForeignKey	Adrian Holovaty	Adrian Holovaty	"sopel had the idea of a {{{GenericForeignKey}}}, which would abstract the concept of ""content_type_id"" and ""object_id"". Basically, it'd be a way to relate an object to ""one of several types of objects.""

For example, we currently have this in the {{{Comment}}} model:

{{{
#!python
class Comment(meta.Model):
    # ...
    content_type = meta.ForeignKey(core.ContentType)
    object_id = meta.IntegerField()
}}}

That could be replaced with this:

{{{
#!python
class Comment(meta.Model):
    # ...
    content_object = meta.GenericForeignKey()
}}}

With that, {{{Comment}}} objects would get an automatic {{{get_content_object()}}} method, which would return whatever object was related, regardless of its type.

This is a messy problem, so we'd have to figure out a couple of loose ends:

 * Does every other object in the system get a {{{get_comment_list}}} method?
 * Do we enforce referential integrity, so that, for example, all the appropriate comments would be deleted if a story was deleted?"	enhancement	closed	Contrib apps		critical	fixed	rthml tab space editor js	hi-world cup	Unreviewed	0	0	0	0	0	0
