On Wed, Jun 27, 2012 at 7:15 PM, Meshy <[email protected]> wrote:
> 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. I feel this is
> wrong.
>
> 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)
>
> I've added an issue on the tracker for
> this: https://code.djangoproject.com/ticket/18525
>
> I realise this may be a contentious issue...or that I may even get shot down
> in flames on this one ;P Go easy on me! :)

I don't think it's particularly contentious -- I'd certainly pay your
premise that Slugs are almost always unique (although as Dan pointed
out, they're often unique with other fields). However, I would make
two comments:

 * There's a backwards compatibility issue. We can't just reverse the
value of the setting, because it would break all existing code. There
might be some ways to introduce it slowly (e.g., the value of an
"undefined" unique setting changes over a couple of releases).
However, even if we were going to go down this path, we still need to
balance the inconvenience of the change against the benefits.

 * Explicit is better than implicit. By default, database fields won't
be unique -- you need to explicitly make them unique. Even though
there's a little bit more typing involved, there's something to be
said for being explicit about making every field unique.

If we had a clean slate, it might be worth reconsidering the default.
However, at this point, the behaviour of SlugField has been the way it
has for 6 years, and it has been, at worst, a minor inconvenience. For
me, given the inconvenience involved in making the change, this issue
just doesn't rise above "meh" level.

Yours,
Russ Magee %-)

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en.

Reply via email to