Django

Code

Ticket #4491 (closed: fixed)

Opened 1 year ago

Last modified 1 year ago

[newforms-admin] addAnother link does not work

Reported by: Honza Král <Honza.Kral@gmail.com> Assigned to: jkocherhans
Milestone: Component: django.contrib.admin
Version: newforms-admin Keywords: newforms admin addAnother
Cc: Triage Stage: Accepted
Has patch: 1 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 1

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

newforms-admin-5427-site_to_admin_opts.diff (3.2 kB) - added by Honza Král <Honza.Kral@gmail.com> on 06/06/07 11:16:16.
propagate site to admin_class
newforms-admin-5519-site_to_admin_opts.diff (3.0 kB) - added by Honza Král <Honza.Kral@gmail.com> on 06/23/07 11:28:22.
new version for current version
site-aware-modeladmin.diff (5.3 kB) - added by jkocherhans on 09/07/07 00:34:20.
This breaks the way StackedInline and TabularInline work, but makes them more like ModelAdmin. Still thinking about this…

Change History

06/06/07 11:16:16 changed by Honza Král <Honza.Kral@gmail.com>

  • attachment newforms-admin-5427-site_to_admin_opts.diff added.

propagate site to admin_class

06/07/07 16:56:41 changed by adrian

  • needs_better_patch changed.
  • version changed from other branch to newforms-admin.
  • needs_tests changed.
  • needs_docs changed.

06/23/07 11:28:22 changed by Honza Král <Honza.Kral@gmail.com>

  • attachment newforms-admin-5519-site_to_admin_opts.diff added.

new version for current version

06/23/07 11:33:27 changed by Honza Král <Honza.Kral@gmail.com>

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.

09/07/07 00:34:20 changed by jkocherhans

  • attachment site-aware-modeladmin.diff added.

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

09/07/07 00:41:49 changed by jkocherhans

  • owner changed from adrian to jkocherhans.
  • needs_better_patch set to 1.
  • status changed from new to assigned.
  • 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.

09/07/07 03:11:42 changed by Honza Král <Honza.Kral@gmail.com>

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

09/09/07 14:15:02 changed by jkocherhans

  • status changed from assigned to closed.
  • resolution set to fixed.

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


Add/Change #4491 ([newforms-admin] addAnother link does not work)




Change Properties
Action