#20594 closed Bug (fixed)

models.SlugField doesn't validate against slug_re

Reported by: carbonXT 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

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 Changed 21 months ago by claudep

  • Easy pickings set
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted
  • Type changed from Uncategorized to Bug

comment:2 Changed 21 months ago by bmispelon

  • Cc bmispelon@… added
  • Owner changed from nobody to bmispelon
  • Status changed from new to assigned

comment:3 Changed 21 months ago by bmispelon

  • Has patch set
  • Owner bmispelon deleted
  • Status changed from assigned to new

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

  • Owner set to Tim Graham <timograham@…>
  • Resolution set to fixed
  • Status changed from new to closed

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