Code

Opened 3 years ago

Closed 3 years ago

#16485 closed Bug (worksforme)

Admin URL bug with CharField primary keys

Reported by: sbaechler 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

Attachments (0)

Change History (4)

comment:1 Changed 3 years ago by BernhardEssl

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Design decision needed
  • Version changed from 1.3 to SVN

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 3 years ago by ramiro

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

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 3 years ago by sbaechler

  • Resolution worksforme deleted
  • Status changed from closed to reopened
  • Version changed from SVN to 1.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 3 years ago by silent1mezzo

  • Resolution set to worksforme
  • Status changed from reopened to closed

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 3 years ago by silent1mezzo (previous) (diff)

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.