Opened 11 years ago

Closed 11 years ago

#20594 closed Bug (fixed)

models.SlugField doesn't validate against slug_re

Reported by: Mike Fogel Owned by: Tim Graham <timograham@…>
Component: Database layer (models, ORM) Version: dev
Severity: Normal Keywords:
Cc: bmispelon@… Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

This appears to be a bug to me:

from django.db import models

class MyModel(models.Model):
    slug = models.SlugField()

mymodel = MyModel(slug='this is an invalid % $ ## slug')
mymodel.full_clean() # it'd expect this to raise a validation error... it does not.

Change History (4)

comment:1 by Claude Paroz, 11 years ago

Easy pickings: set
Triage Stage: UnreviewedAccepted
Type: UncategorizedBug

comment:2 by Baptiste Mispelon, 11 years ago

Cc: bmispelon@… added
Owner: changed from nobody to Baptiste Mispelon
Status: newassigned

comment:3 by Baptiste Mispelon, 11 years ago

Has patch: set
Owner: Baptiste Mispelon removed
Status: assignednew

PR here: https://github.com/django/django/pull/1267

I also included some cleanup of the URLField validators.
Since 9ed6e08ff99c18710c0e4875f827235f04c89d76, the URLField (both model and form field) validator doesn't depend on a parameter passed in __init__ so it can be added directly to URLField.default_validators.

comment:4 by Tim Graham <timograham@…>, 11 years ago

Owner: set to Tim Graham <timograham@…>
Resolution: fixed
Status: newclosed

In dc9c359546580d40df209816cef244b78dcf7435:

Fixed #20594 -- Add validation to models.SlugField.

Thanks carbonXT for the report.

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