Opened 8 years ago

Closed 7 years ago

#6281 closed (duplicate)

models.SlugField has no formfield() method

Reported by: Collin Grady <cgrady@…> Owned by: nobody
Component: Forms Version: master
Severity: Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

At present, models.SlugField returns a forms.CharField since it just inherits the default formfield method from models.CharField - as such, the form does no validation to be sure it's a valid slug.

Attachments (2)

6281-slugfield-formfield.patch (773 bytes) - added by Collin Grady <cgrady@…> 8 years ago.
slugfield-as-regexfield.patch (1.8 KB) - added by Joshua "jag" Ginsberg <jag@…> 7 years ago.

Download all attachments as: .zip

Change History (7)

Changed 8 years ago by Collin Grady <cgrady@…>

comment:1 Changed 8 years ago by SmileyChris

  • Needs documentation unset
  • Needs tests set
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

comment:2 Changed 7 years ago by Joshua "jag" Ginsberg <jag@…>

Another patch for your consideration -- this one follows the model of other formfield methods in that it preserves the values given in kwargs, it contains unit tests, and it is sensitive to max_length.

-jag

Changed 7 years ago by Joshua "jag" Ginsberg <jag@…>

comment:3 Changed 7 years ago by cgrady

  • Needs tests unset

comment:4 Changed 7 years ago by SmileyChris

Looks good, jag.

Don't think you need the max_length line, because the super method will handle this.

comment:5 Changed 7 years ago by mattmcc

  • Resolution set to duplicate
  • Status changed from new to closed

This was duped by #8040, which was fixed in [8477].

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