Opened 8 years ago

Last modified 3 years ago

#19515 assigned Cleanup/optimization

Increase the max_length of Redirect.old_path/new_path

Reported by: s.shanabrook@… Owned by: Saul Shanabrook
Component: contrib.redirects Version: master
Severity: Normal Keywords:
Cc: gavinwahl+gh@… Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: yes
Easy pickings: no UI/UX: no


In django.contrib.redirects the the old_path and new_path have max_length=200. This presents problems when either of the paths has a longer length than 200. URLField used to have a max_length=200, but this was resolved [1477] and isn't even applicable, since the path fields use CharFields, not URLfields.

I would recommend a max_length=2000. URL's with a length over 2000 are not as well supported. However since database enforcement of CharFields in MySQL is limited to 255 characters, the fields have to be also changed to TextFields.

Change History (10)

comment:1 Changed 8 years ago by Saul Shanabrook <s.shanabrook@…>

Keywords: redirects removed
Owner: changed from nobody to anonymous
Patch needs improvement: set
Status: newassigned

comment:2 Changed 8 years ago by Saul Shanabrook

Owner: changed from anonymous to Saul Shanabrook

comment:3 Changed 8 years ago by Saul Shanabrook

Version: 1.4master

comment:4 Changed 8 years ago by Saul Shanabrook

Has patch: set

comment:5 Changed 8 years ago by Aymeric Augustin

Easy pickings: unset
Triage Stage: UnreviewedSomeday/Maybe

Thanks for the suggestion. The problem here isn't to change the max_size — it's to provide a suitable upgrade path for existing users. Otherwise, application-level and database-level constraints won't match any longer, which will result in uncaught errors.

In general we've postponed this kind of requests to after Django gets built-in migrations — most likely 1.6 or 1.7.

(By the way a CharField is fine. We don't need a textarea to copy-paste an URL.)

Last edited 8 years ago by Aymeric Augustin (previous) (diff)

comment:6 Changed 7 years ago by s.shanabrook@…

Even though we don't need the form provided by a CharField, MySQL limits unique Charfields to 255 characters:

"Any fields that are stored with VARCHAR column types have their max_length restricted to 255 characters if you are using unique=True for the field. This affects CharField, SlugField and CommaSeparatedIntegerField."

comment:7 Changed 5 years ago by Tim Graham

Summary: Redirect path fields arbitrarily shortIncrease the max_length of Redirect.old_path/new_path
Triage Stage: Someday/MaybeAccepted

comment:8 Changed 4 years ago by Gavin Wahl

Cc: gavinwahl+gh@… added

Django now has built-in migrations. Is this feasible now?

comment:9 Changed 4 years ago by Tim Graham

I'd think so (hence why I moved the ticket to accepted).

comment:10 Changed 3 years ago by Claude Paroz

This will be far easier once #28661 is fixed.

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