Django

Code

Ticket #231 (closed: fixed)

Opened 3 years ago

Last modified 1 year ago

[patch] Make appropriate model fields honor max_length param

Reported by: nesh <nesh [at] studioquattro [dot] co [dot] yu> Assigned to: donspaulding
Milestone: Component: Metasystem
Version: Keywords: FileFields max_length sprintsept14
Cc: Triage Stage: Ready for checkin
Has patch: 1 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

Description

Add maxlength option to FileField? or another way to set maximum length. I have problem with long paths get truncated when file is posted.

Another solution is to store file names relative to upload_to parameter.

Attachments

maxlength_for_filefields.diff (5.3 kB) - added by mssnlayam@yahoo.com on 01/28/07 00:21:31.
Patch
max_length_cleanups.diff (6.8 kB) - added by donspaulding on 09/18/07 15:23:57.
For posterity.
max_length_cleanups_with_docs.diff (13.0 kB) - added by donspaulding on 09/18/07 15:25:08.
Cleaned up handling of max_length in model fields, form fields, and added documentation. Tests included.

Change History

08/15/05 11:35:29 changed by adrian

  • summary changed from add maxlenght to FileField to Add maxlength option to FileFields.

02/20/06 10:12:08 changed by donald-curtis@uiowa.edu

did this get closed? it really should exist, i had to manually update the table to accept the longer path names. and yes, for portability there shouldn't be full paths in my opinion.

01/19/07 04:48:26 changed by Simon G. <dev@simon.net.nz>

  • keywords set to FileFields.
  • stage changed from Unreviewed to Accepted.

01/28/07 00:21:31 changed by mssnlayam@yahoo.com

  • attachment maxlength_for_filefields.diff added.

Patch

01/28/07 00:22:49 changed by anonymous

  • has_patch set to 1.
  • summary changed from Add maxlength option to FileFields to [patch] Add maxlength option to FileFields.

01/28/07 09:10:30 changed by mssnlayam@yahoo.com

  • needs_better_patch set to 1.

The manipulators code needs to be changed as well to support this. This patch is incomplete.

09/14/07 23:46:27 changed by donspaulding

  • owner changed from nobody to donspaulding.
  • summary changed from [patch] Add maxlength option to FileFields to [patch] Make appropriate model fields honor max_length param.
  • stage changed from Accepted to Design decision needed.

I think model fields in db/models/fields/init.py need to deal with max_length in a consistent manner. They can keep their old hard-coded values if a kwarg isn't provided, but otherwise, they should use the provided one. Latest patch should reflect those changes.

09/15/07 13:41:37 changed by donspaulding

  • needs_better_patch deleted.
  • needs_tests set to 1.
  • stage changed from Design decision needed to Accepted.

09/15/07 14:35:46 changed by donspaulding

  • keywords changed from FileFields to FileFields sprintsept14.

09/15/07 20:52:38 changed by PhiR

  • owner changed from donspaulding to PhiR.
  • status changed from new to assigned.

might solve #5315.

09/16/07 00:18:29 changed by donspaulding

  • owner changed from PhiR to donspaulding.
  • status changed from assigned to new.

09/16/07 00:18:54 changed by donspaulding

  • status changed from new to assigned.

09/16/07 00:22:08 changed by donspaulding

  • needs_tests deleted.

09/16/07 08:40:49 changed by PhiR

  • needs_better_patch set to 1.

The patch looks nice. I've checked that all backends are covered. One small nitpick: the doc says max_length only exist in the dev version, maybe it would be more generic to say that it is only supported in version > .96. I've had to touch tests/regressiontests/max_lengths/init.py to make the tests works though, it should be added in the patch (if possible, i know svn is tricky with empty files).

09/16/07 23:00:47 changed by donspaulding

  • keywords changed from FileFields sprintsept14 to FileFields max_length sprintsept14.
  • needs_better_patch deleted.

Phir, good catch on the init file, I added a blank line so Trac's diff display would pick it up, though I'm not sure that's the standard way to add init files.

09/16/07 23:18:40 changed by donspaulding

  • stage changed from Accepted to Ready for checkin.

I think this just needs a final once over by a couple of core devs before committing.

09/18/07 15:23:57 changed by donspaulding

  • attachment max_length_cleanups.diff added.

For posterity.

09/18/07 15:25:08 changed by donspaulding

  • attachment max_length_cleanups_with_docs.diff added.

Cleaned up handling of max_length in model fields, form fields, and added documentation. Tests included.

09/19/07 18:33:57 changed by jacob

  • status changed from assigned to closed.
  • resolution set to fixed.

(In [6378]) Fixed #231: all fields that should take max_length now do. Thanks, Don Spaulding.


Add/Change #231 ([patch] Make appropriate model fields honor max_length param)




Change Properties
Action