Created
August 18, 2009 02:11
-
-
Save toastdriven/169498 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
models.py | |
if field.primary_key or field.unique: | |
# You're not as special anymore but we still love you. | |
# Plop an index on it so it's fast. | |
field.primary_key = False | |
field._unique = False | |
field.db_index = True | |
+ # Bugfix: If there's a related_name, it needs to be unique-ish. | |
+ if hasattr(field, 'rel') and field.rel: | |
+ new_rel = copy.copy(field.rel) | |
+ new_rel.related_name = '%s_versioned' % field.rel.related_name | |
+ field.rel = new_rel | |
+ | |
fields[field.name] = field |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment