Opened 14 years ago

Closed 13 years ago

Last modified 12 years ago

#199 closed defect (fixed)

CharField should raise an exception when maxlength is not specified

Reported by: Steadicat Owned by: Adrian Holovaty
Component: Metasystem Version:
Severity: trivial Keywords:
Cc: django@… Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


"maxlength" is a required keyword argument for a CharField, yet no error is raised if the argument is not provided.

The error produces its effect much later when the SQL code containing "varchar(None)" fails.

It would be better for CharField to raise an exception immediately, so as to simplify debugging.

Change History (3)

comment:1 Changed 14 years ago by Steadicat

Cc: django@… added

comment:2 Changed 13 years ago by hugo

An alternative would be to create only "varchar" fields (without length defined), as it is supported with at least sqlite and postgresql. That way one could make use of the PostgreSQL unbound varchars - you can for example index them (you can't index text fields).

comment:3 Changed 13 years ago by Adrian Holovaty

Resolution: fixed
Status: newclosed

The model validator catches this.

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