title: how can i resolve ValueError: Field 'cid' expected a number but got ''.?
body: <p>while performing migration I am getting this error...</p>
  <pre><code>(env) PS C:\Users\ashwi\Documents\GitHub\AMCH\AMCH_Recruiter&gt; python manage.py migrate       
  Operations to perform:
    Apply all migrations: Recruiter, admin, auth, contenttypes, sessions
  Running migrations:
    Applying Recruiter.0003_auto_20211009_2038...Traceback (most recent call last):
    File &quot;C:\Users\ashwi\Documents\GitHub\AMCH\env\lib\site-packages\django\db\models\fields\__init__.py&quot;, line 1823, in get_prep_value
      return int(value)
  ValueError: invalid literal for int() with base 10: ''
  
  The above exception was the direct cause of the following exception:
  
  Traceback (most recent call last):
    File &quot;C:\Users\ashwi\Documents\GitHub\AMCH\AMCH_Recruiter\manage.py&quot;, line 22, in &lt;module&gt;
      main()
    File &quot;C:\Users\ashwi\Documents\GitHub\AMCH\AMCH_Recruiter\manage.py&quot;, line 18, in main
      execute_from_command_line(sys.argv)
    File &quot;C:\Users\ashwi\Documents\GitHub\AMCH\env\lib\site-packages\django\core\management\__init__.py&quot;, line 419, in execute_from_command_line
      utility.execute()
    File &quot;C:\Users\ashwi\Documents\GitHub\AMCH\env\lib\site-packages\django\core\management\__init__.py&quot;, line 413, in execute
      self.fetch_command(subcommand).run_from_argv(self.argv)
    File &quot;C:\Users\ashwi\Documents\GitHub\AMCH\env\lib\site-packages\django\core\management\base.py&quot;, line 354, in run_from_argv
      self.execute(*args, **cmd_options)
    File &quot;C:\Users\ashwi\Documents\GitHub\AMCH\env\lib\site-packages\django\core\management\base.py&quot;, line 398, in execute
      output = self.handle(*args, **options)
    File &quot;C:\Users\ashwi\Documents\GitHub\AMCH\env\lib\site-packages\django\core\management\base.py&quot;, line 89, in wrapped
      res = handle_func(*args, **kwargs)
    File &quot;C:\Users\ashwi\Documents\GitHub\AMCH\env\lib\site-packages\django\core\management\commands\migrate.py&quot;, line 244, in handle
      post_migrate_state = executor.migrate(
    File &quot;C:\Users\ashwi\Documents\GitHub\AMCH\env\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\ashwi\Documents\GitHub\AMCH\env\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\ashwi\Documents\GitHub\AMCH\env\lib\site-packages\django\db\migrations\executor.py&quot;, line 227, in apply_migration
      state = migration.apply(state, schema_editor)
    File &quot;C:\Users\ashwi\Documents\GitHub\AMCH\env\lib\site-packages\django\db\migrations\migration.py&quot;, line 126, in apply
      operation.database_forwards(self.app_label, schema_editor, old_state, project_state)
    File &quot;C:\Users\ashwi\Documents\GitHub\AMCH\env\lib\site-packages\django\db\migrations\operations\fields.py&quot;, line 104, in database_forwards
      schema_editor.add_field(
    File &quot;C:\Users\ashwi\Documents\GitHub\AMCH\env\lib\site-packages\django\db\backends\sqlite3\schema.py&quot;, line 330, in add_field
      self._remake_table(model, create_field=field)
    File &quot;C:\Users\ashwi\Documents\GitHub\AMCH\env\lib\site-packages\django\db\backends\sqlite3\schema.py&quot;, line 191, in _remake_table
      self.effective_default(create_field)
    File &quot;C:\Users\ashwi\Documents\GitHub\AMCH\env\lib\site-packages\django\db\backends\base\schema.py&quot;, line 324, in effective_default
      return field.get_db_prep_save(self._effective_default(field), self.connection)
    File &quot;C:\Users\ashwi\Documents\GitHub\AMCH\env\lib\site-packages\django\db\models\fields\__init__.py&quot;, line 842, in get_db_prep_save
      return self.get_db_prep_value(value, connection=connection, prepared=False)
    File &quot;C:\Users\ashwi\Documents\GitHub\AMCH\env\lib\site-packages\django\db\models\fields\__init__.py&quot;, line 2486, in get_db_prep_value
      value = self.get_prep_value(value)
    File &quot;C:\Users\ashwi\Documents\GitHub\AMCH\env\lib\site-packages\django\db\models\fields\__init__.py&quot;, line 1825, in get_prep_value
      raise e.__class__(
  ValueError: Field 'cid' expected a number but got ''.
  </code></pre>
  <p>models.py</p>
  <pre><code>from django.db import models
  import random
  from django.db.models.deletion import CASCADE
  
  from django.db.models.fields import AutoField
  
  class candidate(models.Model):
      fname=models.CharField(&quot;First name &quot;,max_length=20,default=&quot;&quot;)
      lname=models.CharField(&quot;Last name &quot;,max_length=20,default=&quot;&quot;)
      email=models.EmailField(&quot;Email &quot;,max_length=254,primary_key=True)
      password=models.CharField(&quot;Password &quot;,max_length=100,default=&quot;&quot;)
      
      def __str__(self):
          return self.email #self.fname+&quot; &quot; +self.lname
  
  class employer(models.Model):
      fname=models.CharField(&quot;First name &quot;,max_length=20,default=&quot;&quot;)
      lname=models.CharField(&quot;Last name &quot;,max_length=20,default=&quot;&quot;)
      email=models.EmailField(&quot;Email &quot;,max_length=254,default=&quot;&quot;)
      password=models.CharField(&quot;Password &quot;,max_length=100,default=&quot;&quot;)
  
      def __str__(self):
          return self.fname+&quot; &quot; +self.lname
  
  
  class canDetails(models.Model):
      candEmail=models.ForeignKey(candidate,on_delete=models.CASCADE)
      location=models.CharField(&quot;location &quot;,max_length=30)
      role=models.CharField(&quot;role &quot;,max_length=20)
      cv=models.FileField(upload_to=&quot;media/canDetails/&quot;,default=&quot;&quot;)
  
      def __str__(self):
          return self.candEmail
  
  
  class empDetails(models.Model):
      empEmail=models.ForeignKey(candidate,on_delete=models.CASCADE)
      cmpName=models.CharField(&quot;Company Name &quot;,max_length=30)
      role=models.CharField(&quot;role &quot;,max_length=20)
      cv=models.FileField(upload_to=&quot;media/empDetails/&quot;,default=&quot;&quot;)
  
      def __str__(self):
          return self.empEmail
  
  class jobs(models.Model):
      empEmail=models.ForeignKey(candidate,on_delete=models.CASCADE)
      location=models.CharField(&quot;Location &quot;,max_length=30)
      desc=models.CharField(&quot;Descriptions &quot;,max_length=3000)
      role=models.CharField(&quot;role &quot;,max_length=20)
      sal=models.CharField(&quot;salary &quot;,max_length=20)
  
      def __str__(self):
          return self.empEmail
  </code></pre>
  <p>maybe I have created a primary key with the name cid , assuming this, I have deleted the models I have created before and recreated the models, and still, I am getting these error
  where is the error comes from? any suggestions would be appreciated ..:&gt;</p>
  <p>the latest migrations are
  <strong>0012_alter_candetails_cv.py</strong></p>
  <pre><code># Generated by Django 3.2.8 on 2021-10-13 19:01
  
  from django.db import migrations, models
  import django.db.models.deletion
  
  
  class Migration(migrations.Migration):
  
      initial = True
  
      dependencies = [
          ('Recruiter', '0010_auto_20211014_0024'),
      ]
  
      operations = [
          migrations.CreateModel(
              name='candidate',
              fields=[
                  ('fname', models.CharField(default='', max_length=20, verbose_name='First name ')),
                  ('lname', models.CharField(default='', max_length=20, verbose_name='Last name ')),
                  ('email', models.EmailField(max_length=254, primary_key=True, serialize=False, verbose_name='Email ')),
                  ('password', models.CharField(default='', max_length=100, verbose_name='Password ')),
              ],
          ),
          migrations.CreateModel(
              name='employer',
              fields=[
                  ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                  ('fname', models.CharField(default='', max_length=20, verbose_name='First name ')),
                  ('lname', models.CharField(default='', max_length=20, verbose_name='Last name ')),
                  ('email', models.EmailField(default='', max_length=254, verbose_name='Email ')),
                  ('password', models.CharField(default='', max_length=100, verbose_name='Password ')),
              ],
          ),
          migrations.CreateModel(
              name='jobs',
              fields=[
                  ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                  ('location', models.CharField(max_length=30, verbose_name='Location ')),
                  ('desc', models.CharField(max_length=3000, verbose_name='Descriptions ')),
                  ('role', models.CharField(max_length=20, verbose_name='role ')),
                  ('sal', models.CharField(max_length=20, verbose_name='salary ')),
                  ('empEmail', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='Recruiter.candidate')),
              ],
          ),
          migrations.CreateModel(
              name='empDetails',
              fields=[
                  ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                  ('cmpName', models.CharField(max_length=30, verbose_name='Company Name ')),
                  ('role', models.CharField(max_length=20, verbose_name='role ')),
                  ('cv', models.FileField(default='', upload_to='media/empDetails/')),
                  ('empEmail', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='Recruiter.candidate')),
              ],
          ),
          migrations.CreateModel(
              name='canDetails',
              fields=[
                  ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                  ('location', models.CharField(max_length=30, verbose_name='location ')),
                  ('role', models.CharField(max_length=20, verbose_name='role ')),
                  ('cv', models.FileField(default='', upload_to='media/canDetails/')),
                  ('candEmail', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='Recruiter.candidate')),
              ],
          ),
      ]
  </code></pre>
  <p>and this was the previous migration where i created <code>cid</code></p>
  <p><strong>0004_alter_candidate_cid.py</strong>
  class Migration(migrations.Migration):</p>
  <pre><code>    dependencies = [
          ('Recruiter', '0003_auto_20211009_2038'),
      ]
  
      operations = [
          migrations.AlterField(
              model_name='candidate',
              name='cid',
              field=models.AutoField(default=101, primary_key=True, serialize=False, verbose_name='candidate id'),
          ),
      ]
  
  
  
  
  
  
  
  
  
  
  
  # Generated by Django 3.2.8 on 2021-10-09 15:08
  
  from django.db import migrations, models
  
  
  class Migration(migrations.Migration):
  </code></pre>
  <p><strong>0003_auto_20211009_2038.cpython-39.py</strong></p>
  <pre><code>dependencies = [
          ('Recruiter', '0002_auto_20211009_2003'),
      ]
  
      operations = [
          migrations.RemoveField(
              model_name='candidate',
              name='id',
          ),
          migrations.AddField(
              model_name='candidate',
              name='cid',
              field=models.AutoField(default='', primary_key=True, serialize=False, verbose_name='candidate id'),
          ),
          migrations.AlterField(
              model_name='candetails',
              name='file',
              field=models.FileField(default='', max_length=254, upload_to='', verbose_name='CV '),
          ),
          migrations.AlterField(
              model_name='candetails',
              name='location',
              field=models.CharField(default='', max_length=20, verbose_name='Location '),
          ),
          migrations.AlterField(
              model_name='candetails',
              name='role',
              field=models.CharField(default='', max_length=20, verbose_name='role '),
          ),
          migrations.AlterField(
              model_name='employer',
              name='email',
              field=models.EmailField(default='', max_length=254, verbose_name='Email '),
          ),
          migrations.AlterField(
              model_name='employer',
              name='fname',
              field=models.CharField(default='', max_length=20, verbose_name='First name '),
          ),
          migrations.AlterField(
              model_name='employer',
              name='lname',
              field=models.CharField(default='', max_length=20, verbose_name='Last name '),
          ),
          migrations.AlterField(
              model_name='employer',
              name='password',
              field=models.CharField(default='', max_length=100, verbose_name='Password '),
          ),
      ]
  </code></pre>