Skip to content

Instantly share code, notes, and snippets.

@toastdriven
Created August 18, 2009 02:11
Show Gist options
  • Save toastdriven/169498 to your computer and use it in GitHub Desktop.
Save toastdriven/169498 to your computer and use it in GitHub Desktop.
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