title: How to dynamically validate data in django models
body: <p>I have 10 model classes and I wanted to check whether the passed data is available in table or not. I've a plan in mind that I can create a function which will take arguments of modelclass name, attribute to check and value of that field. 
  from data import models</p>
  
  <pre><code>def IsAvailable(model, attr, val):
    # Here I wanted to create object of given model class and validate whether the attr has the give value.
    obj = getattr(models, model)
    res = obj.objects.get(attr=val)
    return res
  </code></pre>
  
  <p>This will not work because <code>attr</code> is not a field in the given model. Can somebody help me here ?</p>