def update_users(self, user, sender, instance, **kwargs): # We need to make sure the user is authenticated first (e.g. not a SimpleLazyObject) if user is None or user.is_authenticated(): registry = FieldRegistry() if sender in registry: for field in registry.get_fields(sender): setattr(instance, field.name, user)
def contribute_to_class(self, cls, name): super(CurrentUserField, self).contribute_to_class(cls, name) registry = FieldRegistry() registry.add_field(cls, self)
def update_users(self, user, sender, instance, **kwargs): registry = FieldRegistry() if sender in registry: for field in registry.get_fields(sender): setattr(instance, field.name, user)