Hi, I know natural keys possibly will be added to auth.user and group in 1.4. I'm using 1.2 currently and I'm trying to add them dynamically:
class UserManager(models.Manager): def get_by_natural_key(self, username, first_name): return self.get(username=username, first_name=first_name) class GroupManager(models.Manager): def get_by_natural_key(self, name): return self.get(name=name) def unatural_key(self): return (self.username, self.first_name) def gnatural_key(instance): return (self.name,) User.objects = UserManager() Group.objects = GroupManager() User.natural_key = unatural_key Group.natural_key = gnatural_key It seems like it should work.. (?) but I get this error when trying to serialize using natural keys: Traceback (most recent call last): File "data.py", line 362, in <module> Backup().main() File "data.py", line 333, in main if options.dump : self.do_dump(default_datafile, self.classes) File "data.py", line 232, in do_dump use_natural_keys=True) File "/usr/local/lib/python2.6/dist-packages/django/core/serializers/ __init__.py", line 87, in serialize s.serialize(queryset, **options) File "/usr/local/lib/python2.6/dist-packages/django/core/serializers/ base.py", line 39, in serialize for obj in queryset: File "/usr/local/lib/python2.6/dist-packages/django/db/models/ query.py", line 106, in _result_iter self._fill_cache() File "/usr/local/lib/python2.6/dist-packages/django/db/models/ query.py", line 760, in _fill_cache self._result_cache.append(self._iter.next()) File "/usr/local/lib/python2.6/dist-packages/django/db/models/ query.py", line 230, in iterator fields = self.model._meta.fields AttributeError: 'NoneType' object has no attribute '_meta' Is there a way to do this without patching django? thanks, -ak -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.