﻿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
4667	[newforms-admin] add edit_inline support for generic relations	Honza Král <Honza.Kral@…>	Brian Rosner	"I have a model that looks like (working example)
{{{
from django.db import models
from django.contrib.contenttypes import generic
from django.contrib.contenttypes.models import ContentType

class Dependency( models.Model ): 
    target_ct = models.ForeignKey( ContentType, related_name='dependency_for_set' )
    target_id = models.IntegerField()
       
    target = generic.GenericForeignKey( 'target_ct', 'target_id' )
       
    source_ct = models.ForeignKey( ContentType, related_name='dependent_on_set' )
    source_id = models.IntegerField()
       
    source = generic.GenericForeignKey( 'source_ct', 'source_id' )
}}}
and I want to be able to edit it inline with other models, but the current implementations only support edit_inline for foreign key relations. With the attached patch I can do something like this:
{{{
from django.contrib import admin

class SomeModel( models.Model ): 
    text = models.TextField()
       
class SomeModelOptions( admin.ModelAdmin ): 
    inlines = [ admin.TabularInline( Dependency, name='source_ct:source_id', formset=generic.GenericInlineFormset ), ]

admin.site.register( SomeModel , SomeModelOptions )
}}}

The patch is very rough, but working (tested adding and editing). 

I have some questions for the authors (I will post it to django-dev):
 * InlineFormset.rel_name is not really applicable in this case, what would be best to use as a prefix (the value in tha patch - {{{'aaa'}}} is far from ideal ;) )
 * I moved some of the functionality to FormSet (add_fk), to allow for custom binding between objects and use {{{content_type_field:object_id_field}}} as the foreign key name to pass that information. I feel that its not the most elegant solution, could anybody help me out here with some ideas?

btw. Great work, Joseph Kocherhans, your implementation of edit_inline really made this easy for me, thanks."		closed	contrib.admin	dev		fixed	nfa-someday edit_inline generic content_type sprintsept14 ep2008	paltman@… simon@… semente@… peschler@… prufrocks@… smcoll@… dev@…	Accepted	1	0	0	1	0	0
