Opened 4 years ago

Last modified 8 months 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

Description

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 (9)

comment:1 Changed 4 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 4 years ago by Saul Shanabrook

Owner: changed from anonymous to Saul Shanabrook

comment:3 Changed 4 years ago by Saul Shanabrook

Version: 1.4master

comment:4 Changed 4 years ago by Saul Shanabrook

Has patch: set

comment:5 Changed 4 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 4 years ago by Aymeric Augustin (previous) (diff)

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

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

https://docs.djangoproject.com/en/dev/ref/databases/#character-fields

"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 16 months 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 8 months ago by Gavin Wahl

Cc: gavinwahl+gh@… added

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

comment:9 Changed 8 months ago by Tim Graham

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

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