Opened 9 years ago

Closed 8 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:


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@…> 9 years ago.
slugfield-as-regexfield.patch (1.8 KB) - added by Joshua "jag" Ginsberg <jag@…> 9 years ago.

Download all attachments as: .zip

Change History (7)

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

comment:1 Changed 9 years ago by Chris Beaven

Needs documentation: unset
Needs tests: set
Patch needs improvement: unset
Triage Stage: UnreviewedAccepted

comment:2 Changed 9 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.


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

comment:3 Changed 8 years ago by Collin Grady

Needs tests: unset

comment:4 Changed 8 years ago by Chris Beaven

Looks good, jag.

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

comment:5 Changed 8 years ago by Matt McClanahan

Resolution: duplicate
Status: newclosed

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

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