﻿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
10939	Allow for dynamic registration of inlines into an admin model	zbyte64	nobody	"It used to be (django 0.96) you could arbitrarily add inlines into an admin model:


{{{
from django.db import models
from django.contrib.models import FlatPage

class FlatPageAttachment(models.Model):
    flatpage = models.ForeignKey(FlatPage, edit_inline=True)
    attachment = models.FileField(upload_to=""flatpages"")

}}}

Now this is not possible. You could try to import the FlatPage admin and attach an admin inline, but this will not work. The reason for this is that when the Admin model is registered into the admin site, it goes through and populates inline_instances. It is true you could unregister and re-register, but what if another app also wanted to add an inline? If that was the case then only one would get its inline registered.

Perhaps a better alternative is to add a method to ModelAdmin called ""register_inline"". It would behave something like the following:

{{{
def register_inline(self, inline_class):
    inline_instance = inline_class(self.model, self.admin_site)
    self.inline_instances.append(inline_instance)
}}}
"		closed	contrib.admin	1.0		invalid	inlines	zbyte64@…	Unreviewed	0	0	0	0		
