Code

Opened 7 years ago

Closed 7 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: UI/UX:

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@…> 7 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@…> 7 years ago.
new version for current version
site-aware-modeladmin.diff (5.3 KB) - added by jkocherhans 7 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)

Changed 7 years ago by Honza Král <Honza.Kral@…>

propagate site to admin_class

comment:1 Changed 7 years ago by adrian

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Version changed from other branch to newforms-admin

Changed 7 years ago by Honza Král <Honza.Kral@…>

new version for current version

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

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.

Changed 7 years ago by jkocherhans

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

comment:3 Changed 7 years ago by jkocherhans

  • Owner changed from adrian to jkocherhans
  • Patch needs improvement set
  • Status changed from new to assigned
  • Triage Stage changed from Unreviewed to Accepted

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 Changed 7 years ago by Honza Král <Honza.Kral@…>

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 Changed 7 years ago by jkocherhans

  • Resolution set to fixed
  • Status changed from assigned to closed

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

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.