@receiver(pre_save, sender=User)
def disable_anon_user_password_save(sender, **kwargs):
 instance = kwargs['instance']
 if ((instance.username == ANONYMOUS_USER_NAME) and instance.has_usable_password()):
  raise ValueError('Anonymous user can not have usable password!')

@ receiver ( pre_save , sender = User ) def disable_anon_user_password_save ( sender , ** kwargs ) : instance = kwargs [ 'instance' ] if ( ( instance . username == ANONYMOUS_USER_NAME ) and instance . has_usable_password ( ) ) : raise ValueError ( 'Anonymous user can not have usable password!' )
blocks setting password for anonymous user .