Code

Opened 6 years ago

Closed 5 years ago

Last modified 3 years ago

#9341 closed (fixed)

Adding a completely new item via raw_id_fields overwrites contents of the many-to-many field

Reported by: dhancock@… Owned by: nobody
Component: contrib.admin Version: 1.0
Severity: Keywords: raw_id_fields many-to-many
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

Steps to reproduce:

Define a many-to-many field, use raw_id_fields for the admin.
Populate the field in the admin with one or more IDs.
In the admin, click its magnifying glass.
Click Add on the index page, and add one.
Click Save.

You're automatically returned to the admin page with ONLY the new ID showing up in the field. This behavior is great for most foreign keys, but for many-to-many fields, it risks losing previous entries.

Attachments (0)

Change History (6)

comment:1 Changed 6 years ago by adroffne@…

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

This feature is working. I'll give an example based on my code.

I have a ManyToMany field with a defined through model class. It has a tabular Inline admin class using raw_id_fields. I see a separate form field for each relationship, as the primary key.

Next to every field is a magnifying glass to search and choose a primary key. The pop-up window looks like the admin change-list page. A click on a change-list item sets, or replaces, the raw id in the field.

In order to add more raw ids, the Inline admin class needs an extras=1, or more, attribute. That extras=N is probably all that's wrong.

comment:2 Changed 5 years ago by kmtracey

#10131 reports this again, and has a patch.

comment:3 Changed 5 years ago by jacob

  • milestone set to 1.1
  • Triage Stage changed from Unreviewed to Accepted

comment:4 Changed 5 years ago by jacob

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

(In [10452]) Fixed #9341: add another on ManyToManyFields with raw_id_admins now works correctly.

comment:5 Changed 5 years ago by jacob

(In [10453]) [1.0.X] Fixed #9341: add another on ManyToManyFields with raw_id_admins now works correctly. Backport of r10452 from trunk.

comment:6 Changed 3 years ago by jacob

  • milestone 1.1 deleted

Milestone 1.1 deleted

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.