Opened 5 years ago

Closed 5 years ago

#16485 closed Bug (worksforme)

Admin URL bug with CharField primary keys

Reported by: Simon Bächler Owned by: nobody
Component: contrib.admin Version: 1.3
Severity: Normal Keywords: admin primary_key
Cc: Triage Stage: Design decision needed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

I have the following primary key field:

id = models.CharField(_('id'), max_length=40, primary_key=True)

The value is: 126130274108967_190034094385251 (a Facebook post id)

The admin interface change list correctly shows that id. But the url of the item is
126130274108967_5F190034094385251/ notice the _5F... in the middle.

This causes a 404 every time I create a new entry.

Regards
Simon

Change History (4)

comment:1 Changed 5 years ago by Bernhard Essl

Needs documentation: unset
Needs tests: unset
Patch needs improvement: unset
Triage Stage: UnreviewedDesign decision needed
Version: 1.3SVN

As far as I understand the quote function in util.py https://code.djangoproject.com/browser/django/trunk/django/contrib/admin/util.py#L15 do the escaping.
I'm not sure if this is really a bug.

comment:2 Changed 5 years ago by Ramiro Morales

Resolution: worksforme
Status: newclosed

Can't reproduce this with trunk tip nor the 1.3 release, using this model.

from django.db import models

class FacebookPost(models.Model):
    id = models.CharField('id', max_length=40, primary_key=True)

comment:3 Changed 5 years ago by Simon Bächler

Resolution: worksforme
Status: closedreopened
Version: SVN1.3

I just set up a new project from scratch and created just this model. And I still got the error every time. The 404 happens when I click on save and continue editing.

As BernhardEssl mentioned, the primary keys are quoted which probabely makes sense. But then the 'save and continue editing' function should take the quoting into consideration.

Regards
Simon

comment:4 Changed 5 years ago by Adam Mckerlie

Resolution: worksforme
Status: reopenedclosed

I can verify that the URL is escaped from Trunk (and 1.3, 1.2.6) version but but I can't reproduce the 404 when I click on save and continue editing

Last edited 5 years ago by Adam Mckerlie (previous) (diff)
Note: See TracTickets for help on using tickets.
Back to Top