Question: I have an Ubuntu VM with Redis installed, running on my Windows PC. I have a PHP application that uses Predis to interface with Redis:

```
Predis\Autoloader::register();

try {
  $redis = new Predis\Client(array(
      "scheme" => "tcp",
      "host" => "192.168.1.66",
      "port" => 6379
  ));
$redis->set('foo', 'bar');

}
catch (Exception $e) {
  die($e->getMessage());
}

```

My Redis.conf has #bind 127.0.0.1 commented out, protected-mode no, and port 6379 (I restarted Redis after the change). I can access Redis inside the VM through the redis-cli with no issues, but when trying to access it via my localhost PHP application I continually get:

No connection could be made because the target machine actively refused it. [tcp://192.168.1.66:6379]

Are there any other configuration options needed for my localhost app to reach the VM Redis instance?

\*updated with the correct ip address. Issue persists. Also to note my VM network adapter is set to bridge and I can ping the VM from my local machine.

Answer: 
I think you can look into Model's [clean](https://docs.djangoproject.com/en/2.1/ref/models/instances/#django.db.models.Model.clean) method. You can try like this:

```
from django.core.exceptions import ValidationError

class YourModel(models.Model):
    ...
    def clean(self):
       if self.something is 'wrong':
           raise ValidationError("Something is wrong")

    def save(self, *args, **kwargs):
        self.full_clean()
        return super(YourModel, self).save(*args, **kwargs)

```
If i did understand well your question and your issue, i think you're trying to do something like this example:

```
from django.shortcuts import redirect
from django.urls impot reverse_lazy
# If you want to use the django's messages framework
from django.contrib import messages

class MyCustomView(UpdateProcessView):
    def __init__(self, *args, **kwargs):
        # Initialize the parents of MycustomView class
        super().__init__(self, *args, **kwargs)

    # Then override form_valid method
    def form_valid(self, form):
        # You need to verify is self.model is iterable or not
        # If not, you need to find a way to pass your conditions 
        # with self.model elements
        if 'elm1' in self.model:
            messages.error(self.request, "Condition 1 is not met")
            return redirect(reverse_lazy('my_url1_name'))
        elif 'elm2' in self.model:
            messages.error(self.request, "Condition 2 is not met")
            return redirect(reverse_lazy('my_url2_name'))

        messages.success(self.request, "Valid request")
        # which will return a HttpResponseRedirect
        return super().form_valid()

```