Opened 7 years ago

Closed 7 years ago

Last modified 4 years ago

#7982 closed (fixed)

ModelAdmin primarykeys

Reported by: sorl Owned by: bastih
Component: contrib.admin Version: master
Severity: Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

A models primary keys used with ModelAdmin cannot end with: add, history nor delete. See call method of ModelAdmin in options.py, url scheme probably needs to be changed to fix this.

Attachments (2)

ticket7982against8487.diff (4.6 KB) - added by bastih 7 years ago.
Patch, not yet finished
7982_against_trunk.diff (2.8 KB) - added by bastih 7 years ago.
Patch, doesn't fix /add/ but the other two cases, adds test for all three

Download all attachments as: .zip

Change History (11)

comment:1 Changed 7 years ago by sorl

  • Component changed from Uncategorized to Admin interface
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

comment:2 Changed 7 years ago by bastih

  • Has patch set

Woops, kinda didn't fix it ... looking through it again :P

comment:3 Changed 7 years ago by bastih

  • Has patch unset
  • milestone set to 1.0 maybe
  • Owner changed from nobody to bastih
  • Status changed from new to assigned
  • Triage Stage changed from Unreviewed to Design decision needed

Having looked into this again, i guess one would either have to decouple the actions from the model url or run into those problems over and over again using a char primary key because of those reserved words, or prefix all specific object requests with something like model/objects/pk.

(ignore the patch, wasn't recognizing the real problem)

comment:4 Changed 7 years ago by jacob

  • milestone changed from 1.0 maybe to 1.0
  • Triage Stage changed from Design decision needed to Accepted

(deleted patch just so that I don't get confused.)

Changed 7 years ago by bastih

Patch, not yet finished

comment:5 Changed 7 years ago by bastih

  • Has patch set

The patch changes the url-schema of the admin as following:

app/model/ # No view -> redirects to objects/ (maybe a future "choose your view/manager?")

app/model/objects/ # List view

app/model/objects/pk # Particular object

app/model/objects/pk/action # Action on particular object, history/delete

app/model/add/ # Create a new object

Currently has one left issue, which is marked as a TODO in the ticket, saving an already existing model with saveandnew currently doesn't get the right url (wish i had an admin urlconf to make this patch somewhat nicer).

comment:6 follow-up: Changed 7 years ago by brosner

I don't like this patch right now. It introduces a backward incompatibility in the admin URL schema. This ticket is really a duplicate of #6470, but it was renamed to be the correct fix. The delete and history case and be easily fixed, but the add case is going to be nearly impossible in any case.

Changed 7 years ago by bastih

Patch, doesn't fix /add/ but the other two cases, adds test for all three

comment:7 in reply to: ↑ 6 Changed 7 years ago by bastih

Correction: It fixes all cases but the pk "add".

comment:8 Changed 7 years ago by brosner

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

(In [8704]) Fixed #7982 -- Corrected ModelAdmin url dispatching to ensure it matching exactly what it needs and doesn't stomp on primary key space. 'add' is a lost cause for now. This originated from #6470. Thanks jdetaeye for the original patch and basith for providing test cases.

comment:9 Changed 4 years ago by jacob

  • milestone 1.0 deleted

Milestone 1.0 deleted

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