Code

Opened 8 years ago

Closed 8 years ago

Last modified 7 years ago

#1259 closed defect (fixed)

[magic-removal][patch] mismatch between singular and plural for admin model URLs

Reported by: Tom Tobin <korpios@…> Owned by: adrian
Component: contrib.admin Version:
Severity: normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

There seems to be a mismatch as to how admin model URLs are constructed in magic-removal; as a result, log entries in the admin interface currently do not point to the valid URL path for their corresponding items.

In contrib/admin/templatetags/adminapplist.py, admin_url is built in the singular in the render method of AdminApplistNode:

'admin_url': '%s/%s/' % (app_label, m.__name__.lower()),

In contrib/admin/models.py, such a URL is built with pluralization in the get_admin_url method of LogEntry:

return "%s/%s/%s/" % (self.get_content_type().get_package(), self.get_content_type().python_module_name, self.object_id)

python_module_name, in turn, is originally constructed in db/models/options.py with the following:

get_module_name = lambda class_name: class_name.lower() + 's'

As I'm not certain which is intended as the final case (singular vs. plural), I have refrained from attempting a fix; I'll gladly work up a patch once I know which way this should go.

Attachments (1)

magic_removal-singular_normalization.diff (12.6 KB) - added by Tom Tobin <korpios@…> 8 years ago.
Normalizes all table names to be singular

Download all attachments as: .zip

Change History (4)

comment:1 Changed 8 years ago by Tom Tobin <korpios@…>

  • Summary changed from [magic-removal] mismatch between singular and plural for admin model URLs to [magic-removal][patch] mismatch between singular and plural for admin model URLs

I'm attaching a patch to singularize all the table names, which fixes this ticket and also apparently fixes #1257 as bonus. In addition, this patch alters every table name which formerly went without a leading package (e.g., "content_types") to now begin with "django_", e.g., "django_content_type".

This patch will thoroughly break an existing Django installation; a conversion script is probably necessary for such cases.

Changed 8 years ago by Tom Tobin <korpios@…>

Normalizes all table names to be singular

comment:2 Changed 8 years ago by adrian

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

(In [2111]) magic-removal: Fixed #1259 -- This is VERY backwards-incompatible! Normalized all table names to be singular. Added 'django_' prefix to core tables that didn't have it. Thanks, Tom Tobin.

comment:3 Changed 7 years ago by korpios

  • Reporter changed from Tom Tobin <korpios@…> to Tom Tobin <korpios@…>

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.