Opened 7 years ago

Closed 4 years ago

#7865 closed New feature (wontfix)

Inline Edits across Apps

Reported by: magneto Owned by: nobody
Component: Forms Version: master
Severity: Normal Keywords: newforms-admin edit_inline
Cc: Triage Stage: Design decision needed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

One little feature that is either a) missing or b) not documented that existed in the 'old forms admin' was the ability to 'edit_inline' across Apps

## the 'old way'
# myapp1/models.py
class M1(models.Model):
   col1 = ...

#myapp2/models.py
from mapp1.models. import M1
class M2(models.Model):
   m1 = models.ForeignKey(M1, edit_inline = models.STACKED)
   col1 = ...

The above would make the 'M2' editable inline inside the admin form for M1
This obviously would depend on the Order of the Apps loading in settings (i.e. M1 before M2)

But this is nice little feature and can be replicated with a 'hack' to the new-forms admin of sorts

# in myapp2/admin.py
from myapp1.models import M1
from myapp2.models import M2
from django.contrib import admin

class M2_Inline(admin.StackedInline):
	model = M2

## here it the hack
## get the User instance from the current admin set up and add these inlines
if M1 in admin.site._registry:
	## add to inlines of the base User
	inline_instance = M2_Inline(admin.site._registry[M1].model, admin.site._registry[M1].admin_site)
	admin.site._registry[M1].inline_instances.append(inline_instance)

###

It would be _nice_ to simply have some methods to the _registry of the AdminSite object, and even, perhaps an "AdminSite .add_to_inlines("TargetModel", [List of Other Inlines])

I Imagine this requires some design designs as to weather or to to allow access to the AdminSite overloard object

Attachments (1)

admin_site_add_to_inlines.diff (1.1 KB) - added by magneto 7 years ago.
A 'add_to_inlines' funciton for AdminSite

Download all attachments as: .zip

Change History (5)

Changed 7 years ago by magneto

A 'add_to_inlines' funciton for AdminSite

comment:1 Changed 7 years ago by ericholscher

  • milestone set to post-1.0
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Design decision needed

comment:2 Changed 6 years ago by anonymous

  • milestone post-1.0 deleted

Milestone post-1.0 deleted

comment:3 Changed 4 years ago by lukeplant

  • Severity set to Normal
  • Type set to New feature

comment:4 Changed 4 years ago by Alex

  • Easy pickings unset
  • Resolution set to wontfix
  • Status changed from new to closed
  • UI/UX unset

wontfixing: the correct solution to wanting to alter something's model admin from a differnt app is to unregister the current model admin, subclass it, and register your own.

Note: See TracTickets for help on using tickets.
Back to Top