title: How to write unit test for child object?
body: <p>I'm trying to write a test for my Recipe class.</p>
  <pre><code>from django.contrib.auth.models import User
  
  class Recipe(models.Model):
  
      user = models.ForeignKey(User, on_delete=models.CASCADE)
      title = models.CharField(max_length=100, null=True, blank=True)
      content = models.TextField()
      ingredientNumber = models.IntegerField(default=0)
      date_posted = models.DateTimeField(auto_now_add=True)
  </code></pre>
  <p>What I have so far is this.</p>
  <pre><code>from django.test import TestCase
  from .models import Recipe
  
  class BasicTest(TestCase):
      def test_recipe_fields(self):
          recipe = Recipe()
          recipe.title = &quot;New recipy&quot;
          recipe.content = &quot;Cooking instructions&quot;
          recipe.ingredientNumber = 4
          recipe.save()
  
          record = Recipe.objects.get(pk=1)
          self.assertEqual(record, recipe)
  </code></pre>
  <p>When I run this test, I get this error:
  NOT NULL constraint failed: recipes_recipe.user_id</p>
  <p>How can I create an User instance for this test?</p>