Opened 12 years ago

Closed 12 years ago

#18525 closed Cleanup/optimization (wontfix)

unique should be True by default on SlugField instead of False.

Reported by: anonymous Owned by: nobody
Component: Database layer (models, ORM) Version:
Severity: Normal Keywords: SlugField
Cc: Charlie Denton Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Perhaps it's just me, but I've very rarely wanted a SlugField that wasn't unique. Would this not be a sensible default? I realise that a lot of apps will rely upon this default, but objectively speaking would this not be better? Perhaps this change would be appropriate for django 2.0.

At the moment,

slug = models.SlugField()

creates a non-unique field, and if you want it to be unique, then you must add unique=True.

It seems to me that unique should be default, and if you don't want a unique slug, you should explicitly state that:

slug = models.SlugField(unique=False)

Change History (2)

comment:1 by Charlie Denton, 12 years ago

Cc: Charlie Denton added

Oops! I hit "Post" instead of "Preview". I posted this.

comment:2 by Karen Tracey, 12 years ago

Resolution: wontfix
Status: newclosed

Even if this were not backwards incompatible, it doesn't strike me as a good idea. Having the framework decide for me that "oh you probably want this to be unique" isn't something that appeals to me, nor is having to start keeping track of "these fields have unique=True by default, unlike most fields". While it may be quite common for for unique=True on a SlugField it's not nearly universal: unique together with another field is likely also quite common.

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