Opened 3 years ago

Last modified 4 weeks ago

#19515 assigned Cleanup/optimization

Increase the max_length of Redirect.old_path/new_path

Reported by: s.shanabrook@… Owned by: saulshanabrook
Component: contrib.redirects Version: master
Severity: Normal Keywords:
Cc: 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 (7)

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

  • Keywords redirects removed
  • Needs documentation unset
  • Needs tests unset
  • Owner changed from nobody to anonymous
  • Patch needs improvement set
  • Status changed from new to assigned

comment:2 Changed 3 years ago by saulshanabrook

  • Owner changed from anonymous to saulshanabrook

comment:3 Changed 3 years ago by saulshanabrook

  • Version changed from 1.4 to master

comment:4 Changed 3 years ago by saulshanabrook

  • Has patch set

comment:5 Changed 3 years ago by aaugustin

  • Easy pickings unset
  • Triage Stage changed from Unreviewed to Someday/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.

Version 0, edited 3 years ago by aaugustin (next)

comment:6 Changed 3 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 4 weeks ago by timgraham

  • Summary changed from Redirect path fields arbitrarily short to Increase the max_length of Redirect.old_path/new_path
  • Triage Stage changed from Someday/Maybe to Accepted
Note: See TracTickets for help on using tickets.
Back to Top