Opened 5 years ago

Closed 5 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: master
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


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 Changed 5 years ago by Claude Paroz

Easy pickings: set
Triage Stage: UnreviewedAccepted
Type: UncategorizedBug

comment:2 Changed 5 years ago by Baptiste Mispelon

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

comment:3 Changed 5 years ago by Baptiste Mispelon

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

PR here:

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 Changed 5 years ago by Tim Graham <timograham@…>

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