Django

Code

Ticket #573 (closed: fixed)

Opened 4 years ago

Last modified 3 years ago

[patch] add plus sign to ManyToMany fields in admin

Reported by: hp@syntomax.com Assigned to: adrian
Milestone: Component: django.contrib.admin
Version: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: 1 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

Description

This patch adds the "add-another" button to ManyToMany? fields as well as ManyToOne?.

Makes life a tad easier :)

Index: django/views/admin/main.py
===================================================================
--- django/views/admin/main.py  (revision 712)
+++ django/views/admin/main.py  (working copy)
@@ -752,7 +752,7 @@
     # fields with relationships to editable objects get an "add another" link,
     # but only if the field doesn't have raw_admin ('cause in that case they get
     # the "add" button in the popup)
-    elif field.rel and isinstance(field.rel, meta.ManyToOne) and field.rel.to.admin:
+    elif field.rel and isinstance(field.rel, meta.ManyToOne) or isinstance(field.rel, meta.ManyToMany) and field.rel.to.admin:
         t.append('{%% if perms.%s.%s %%}' % (field.rel.to.app_label, field.rel.to.get_add_permission()))
         t.append(' <a href="../../../%s/%s/add/" class="add-another" id="add_%s" onclick="return showAddAnotherPopup(this);">' % \
                     (field.rel.to.app_label, field.rel.to.module_name, field_id))

Attachments

add_+_to_ManyToMany.diff (0.9 kB) - added by anonymous on 09/28/05 19:27:22.

Change History

09/28/05 19:27:22 changed by anonymous

  • attachment add_+_to_ManyToMany.diff added.

09/28/05 22:14:55 changed by adrian

  • status changed from new to assigned.

09/28/05 22:19:15 changed by adrian

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

(In [714]) Fixed #573 -- Added 'Add another' link to many-to-many fields in admin. Thanks, hp@syntomax.com

01/17/07 16:12:17 changed by

  • milestone deleted.

Milestone Version 1.0 deleted


Add/Change #573 ([patch] add plus sign to ManyToMany fields in admin)




Change Properties
Action