title: TypeError: Field 'id' expected a number but got <User: >
body: <p>I'm using Django and recently remade my Posts Model in models.py, however whenever I try and make migration I get the following error.</p>
  <pre><code>Operations to perform:
    Apply all migrations: admin, auth, blog, contenttypes, sessions
  Running migrations:
    Applying blog.0006_post_author...Traceback (most recent call last):
    File &quot;C:\Users\dylan\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\models\fields\__init__.py&quot;, line 1772, in get_prep_value
      return int(value)
  TypeError: int() argument must be a string, a bytes-like object or a number, not 'User'
  
  The above exception was the direct cause of the following exception:
  
  Traceback (most recent call last):
    File &quot;manage.py&quot;, line 21, in &lt;module&gt;
      main()
    File &quot;manage.py&quot;, line 17, in main
      execute_from_command_line(sys.argv)
    File &quot;C:\Users\dylan\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\management\__init__.py&quot;, line 401, in execute_from_command_line
      utility.execute()
    File &quot;C:\Users\dylan\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\management\__init__.py&quot;, line 395, in execute
      self.fetch_command(subcommand).run_from_argv(self.argv)
    File &quot;C:\Users\dylan\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\management\base.py&quot;, line 328, in run_from_argv
      self.execute(*args, **cmd_options)
    File &quot;C:\Users\dylan\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\management\base.py&quot;, line 369, in execute
      output = self.handle(*args, **options)
    File &quot;C:\Users\dylan\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\management\base.py&quot;, line 83, in wrapped
      res = handle_func(*args, **kwargs)
    File &quot;C:\Users\dylan\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\management\commands\migrate.py&quot;, line 231, in handle
      post_migrate_state = executor.migrate(
    File &quot;C:\Users\dylan\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\migrations\executor.py&quot;, line 117, in migrate
      state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, fake_initial=fake_initial)
    File &quot;C:\Users\dylan\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\migrations\executor.py&quot;, line 147, in _migrate_all_forwards
      state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial)
    File &quot;C:\Users\dylan\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\migrations\executor.py&quot;, line 245, in apply_migration
      state = migration.apply(state, schema_editor)
    File &quot;C:\Users\dylan\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\migrations\migration.py&quot;, line 124, in apply
      operation.database_forwards(self.app_label, schema_editor, old_state, project_state)
    File &quot;C:\Users\dylan\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\migrations\operations\fields.py&quot;, line 110, in database_forwards
      schema_editor.add_field(
    File &quot;C:\Users\dylan\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\backends\sqlite3\schema.py&quot;, line 328, in add_field
      self._remake_table(model, create_field=field)
    File &quot;C:\Users\dylan\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\backends\sqlite3\schema.py&quot;, line 189, in _remake_table
      self.effective_default(create_field)
    File &quot;C:\Users\dylan\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\backends\base\schema.py&quot;, line 303, in effective_default
      return field.get_db_prep_save(self._effective_default(field), self.connection)
    File &quot;C:\Users\dylan\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\models\fields\related.py&quot;, line 939, in get_db_prep_save
      return self.target_field.get_db_prep_save(value, connection=connection)
    File &quot;C:\Users\dylan\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\models\fields\__init__.py&quot;, line 821, in get_db_prep_save
      return self.get_db_prep_value(value, connection=connection, prepared=False)
    File &quot;C:\Users\dylan\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\models\fields\__init__.py&quot;, line 2365, in get_db_prep_value
      value = self.get_prep_value(value)
    File &quot;C:\Users\dylan\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\models\fields\__init__.py&quot;, line 1774, in get_prep_value
      raise e.__class__(
  TypeError: Field 'id' expected a number but got &lt;User: &gt;.
  
  </code></pre>
  <p>Here is my models.py file:</p>
  <pre><code>from django.db import models
  from django.contrib.auth.models import User
  from django.db.models.signals import pre_save
  from django.utils.text import slugify
  from django.conf import settings
  from django.db.models.signals import post_delete
  from django.dispatch import receiver
  from PIL import Image
  
  def upload_location(instance, filename, **kwargs):
      file_path = 'blog/{author.id}/{title}-{filename}'.format(
      author_id = str(instance.author.id), title=str(instance.title), filename=filename
      )
      return file_path
  
  class BlogPost(models.Model):
      title           = models.CharField(max_length=50, null=False, blank=False)
      description     = models.CharField(max_length=500, null=False, blank=False)
      image           = models.ImageField(upload_to=upload_location, null=False, blank=False)
      date_published  = models.DateTimeField(auto_now_add=True, verbose_name=&quot;date published&quot;)
      date_updated    = models.DateTimeField(auto_now=True, verbose_name=&quot;date updated&quot;)
      author          = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE)
      slug            = models.SlugField(blank=True, unique=True)
  
      def __str__(self):
          return self.title
  
  @receiver(post_delete, sender=BlogPost)
  def submission_delete(sender, instance, **kwargs):
      instance.image.delete(False)
  
  def pre_save_blog_post_reciever(sender, instance, *args, **kwargs):
      if not instance.slug:
          instance.slug = slugify(instance.author.username + &quot;-&quot; + instance.title)
  
  pre_save.connect(pre_save_blog_post_reciever, sender=BlogPost)
  </code></pre>
  <p>Here is my admin.py file:</p>
  <pre><code>from django.contrib import admin
  from .models import BlogPost
  # Register your models here.
  admin.site.register(BlogPost)
  </code></pre>