django models objects filter
- by ha22109
Hello All,
I have a model 'Test' ,in which i have 2 foreignkey
models.py
class Test(models.Model):
id =models.Autofield(primary_key=True)
name=models.ForeignKey(model2)
login=models.ForeignKey(model1)
status=models.CharField(max_length=200)
class model1(models.Model):
id=models.CharField(primary_key=True)
.
.
is_active=models.IntergerField()
class model2(model.Model):
id=models.ForeignKey(model1)
.
.
status=model.CharField(max_length=200)
When i add object in model 'Test' , if i select certain login then only the objects related to that objects(model2) should be shown in field 'name'.How can i achieve this.THis will be runtime as if i change the login field value the objects in name should also change.