Browse files

Fixed an important issue in _pre_save, that prevents loading fixtures…

… of models that are registered for translation.

Or more generally, saving new records with pk specified.
  • Loading branch information...
botondus authored and gvangool committed Jul 1, 2010
1 parent d588c49 commit fc8b413985f01374fd8594ea8adf568cc6332f39
Showing with 8 additions and 2 deletions.
  1. +8 −2 datatrans/
@@ -1,5 +1,5 @@
from django.conf import settings
-from django.core.exceptions import ImproperlyConfigured
+from django.core.exceptions import ImproperlyConfigured, ObjectDoesNotExist
from django.db import models
from django.utils import translation
from django.utils.datastructures import SortedDict
@@ -85,9 +85,15 @@ def _pre_save(sender, instance, **kwargs):
# When we edit a registered model, update the original translations and mark them as unedited (to do)
if is not None:
+ try:
+ # Just because is set, it does not mean that the instance
+ # is saved. Most typical/important ex: loading fixtures
+ original = sender.objects.get(
+ except ObjectDoesNotExist:
+ return None
register = get_registry()
fields = register[sender].values()
- original = sender.objects.get(
for field in fields:
old_digest = make_digest(original.__dict__[])
new_digest = make_digest(instance.__dict__[])

0 comments on commit fc8b413

Please sign in to comment.