Opened 17 years ago

Closed 17 years ago

#4491 closed (fixed)

[newforms-admin] addAnother link does not work

Reported by: Honza Král <Honza.Kral@…> Owned by: jkocherhans
Component: contrib.admin Version: newforms-admin
Severity: Keywords: newforms admin addAnother
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: yes
Easy pickings: no UI/UX: no

Description

Admin cannot recognize models registered with current site in django.contrib.admin.widgets.RelatedFieldWidgetWrapper

The attached patch propagates the site object to the options object so that it will have access to it. It is then passed to RelatedFieldWidgetWrapper so that it can check if a model has admin enabled and decide whether or not to include addAnother() link.

Attachments (3)

newforms-admin-5427-site_to_admin_opts.diff (3.2 KB ) - added by Honza Král <Honza.Kral@…> 17 years ago.
propagate site to admin_class
newforms-admin-5519-site_to_admin_opts.diff (3.0 KB ) - added by Honza Král <Honza.Kral@…> 17 years ago.
new version for current version
site-aware-modeladmin.diff (5.3 KB ) - added by jkocherhans 17 years ago.
This breaks the way StackedInline and TabularInline work, but makes them more like ModelAdmin. Still thinking about this…

Download all attachments as: .zip

Change History (8)

by Honza Král <Honza.Kral@…>, 17 years ago

propagate site to admin_class

comment:1 by Adrian Holovaty, 17 years ago

Version: other branchnewforms-admin

by Honza Král <Honza.Kral@…>, 17 years ago

new version for current version

comment:2 by Honza Král <Honza.Kral@…>, 17 years ago

I added a new version of the patch. The problem is that with current state of things, it won't work - it will break on edit_inline functionality - we would have to either force people to pass site object to the InlineModelAdmin manually (yuck), postpone the creation of InlineModelAdmin until inside the ModelAdmin or abandon this approach completely.

by jkocherhans, 17 years ago

Attachment: site-aware-modeladmin.diff added

This breaks the way StackedInline and TabularInline work, but makes them more like ModelAdmin. Still thinking about this...

comment:3 by jkocherhans, 17 years ago

Owner: changed from Adrian Holovaty to jkocherhans
Patch needs improvement: set
Status: newassigned
Triage Stage: UnreviewedAccepted

Thanks for the ideas Honza Král. It makes perfect sense for both of those classes to know about which AdminSite object they are attached to. I think the newest patch I posted is pretty close, but don't like having to create a class for every single inline. Turning StackedInline and TabulatInline into factory functions would work, but then you have to do some trickery to hang custom methods on those classes and it just feels wrong. I'll think about this some more and maybe get some input at the sprint next week.

comment:4 by Honza Král <Honza.Kral@…>, 17 years ago

we are depending heavily upon the newforms-admin branch, so I hope to be present at the sprint. I will be happy to help.

comment:5 by jkocherhans, 17 years ago

Resolution: fixed
Status: assignedclosed

(In [6074]) newforms-admin: Fixed #4491. Thanks Honza Kral.

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