Created
April 6, 2010 19:01
-
-
Save cklein/357954 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Enforce maximum length contrains | |
for field in instance._meta.fields: | |
if isinstance(field, models.CharField): | |
value = getattr(instance, field.name, '') | |
if len(value) > field.max_length: | |
setattr(instance, field.name, value[:field.max_length]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment