title: foreign key and primary key relation in models in django
body: <p>These models are in two different applications in django. I had created the primary key and foreign key relation between the two tables, but the output is not desired output.</p>
  
  <pre><code>class User(models.Model):
      user_name = models.CharField( max_length=255, default=None)
      email = models.CharField( max_length=255, default=None)
      mobile_number = models.IntegerField( default=0)
      created_on = models.DateTimeField( auto_now=True)
  
  class Todo(models.Model):
      title = models.CharField( max_length=255, default=None)
      description = models.CharField( max_length=255, default=None)
      created_on = models.DateTimeField(auto_now=True)
      user = models.ForeignKey('Account.User',on_delete=models.CASCADE)
  </code></pre>
  
  <p>Suppose I created a entry in the <code>User</code> table and the id assigned is <code>1</code>, but I can also create a entry in the <code>Todo</code>table with <code>user_id = 2</code> (which is not a valid value according to the rule ), and the entry is created. Can any one suggest why?</p>
  
  <p>In Python shell:</p>
  
  <pre><code>from Account.models import User
  my_user = ( user_name = "Abhis", email = "aa@aa.com", mobile_number = "9999999999", created_on = datetime.datetime.today())
  my_user.save()    
  
  # it will create a row with id 1.
  from ToDo.models import Todo
  my_todo = ( title = "title", description = "description", created_on = datetime.datetime.today(), user_id = 4)
  my_todo.save()
  # the row with this user_id = 4 is created, which must be illegal 
  </code></pre>