It solves the problem. Thanks
Segunda-feira, 7 de Abril de 2014 22:52:15 UTC+1, Marc Aymerich escreveu: > > On Mon, Apr 7, 2014 at 3:04 PM, Emanuel <[email protected] <javascript:>> > wrote: > > Hi all! > > > > I'm have the following models: > > > > Class A(models.Model): > > pass > > > > > > Class Z(models.Model): > > pass > > > > > > Class B(models.Model): > > a = models.ForeignKey(a) > > z = models.ForeignKey(Z) > > > > def __unicode__(self): > > return self.z > > > > > > Class C(models.Model): > > b = models.ForeignKey(B) > > > > > > I Want in the admin add A,B and C objects. > > > > I know how to put inline objects of B in A. Everything works as > expected. > > But I want to create new C's in the same page. Something like having C > as an > > Inline of B, beeing B an Inline of A. It could appear all in popups... > > nested inlines are not currently supported. A work around can be using > a readonly field on B inline that points to a B change view with C > inlines > > > class BInline(admin.TabularInline): > model = B > readonly_fields = ('c_link',) > > def c_link(self, instance): > if not instance.pk: > return '' > url = reverse('admin:app_c_change', args=(instance.pk,)) > popup = 'onclick="return showAddAnotherPopup(this);"' > return '<a href="%s" %s>%s</a>' % (url, popup, instance) > c_link.allow_tags=True > > > class CInline(admin.TabularInline): > model = C > > > class AModelAdmin(admin.ModelAdmin): > inlines = [BInline] > > > class BModelAdmin(admin.ModelAdmin): > inlines = [Cinline] > -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/aec1a1f9-33af-4e31-b2f2-99a548e8b84f%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.

