raise IntegrityError(
django.db.utils.IntegrityError: The row in table 'jobs_jobs' with primary key '1' has an invalid foreign key: jobs_jobs.company_id contains a value 'Google' that does not have a corresponding value in jobs_company.id.
This is the whole error.
I got this when I ran
python manage.py migrate
I am not sure why I am getting this error. I don't have the value 'Google' in the company models.py
Models.py:
class Company(models.Model): #here we telling about the company,all its details
title = models.CharField(max_length=200, null=True, blank=True)
description = models.TextField(null=True, blank=True)
uniqueId = models.CharField(null=True, blank=True, max_length=100 )
companyLogo = models.ImageField(default = 'default.png', upload_to = 'upload_imges')
slug = models.SlugField(max_length=500, unique=True, null=True, blank=True)
seoDescription = models.CharField(max_length=500, null=True, blank=True)
seoKeywords = models.CharField(max_length=500, null=True, blank=True)
def __str__(self):
return '{} - {}'.format(self.title, self.uniqueId)
def get_absolute_url(self):
return reverse('company-detail', kwargs = {'slug': self.slug })
def save(self, *args, **kwargs):
if self.uniqueId is None:
self.uniqueId = str(uuid4()).split('-')[0]
self.slug = slugify('Company {} {}'.format(self.title, self.uniqueId))
self.slug = slugify('Category {} {}'.format(self.title, self.uniqueId))
self.seoDescription = 'Apply for {} Jobs online, start your career journey today'.format(self.title)
self.seoKeywords = '{}, Jobs, Careers Portal, Apply Jobs'.format(self.title)
super(Company, self).save(*args, **kwargs)
class Jobs(models.Model):
title = models.CharField(max_length=200, null=True, blank=True)
company = models.ForeignKey(Company, on_delete=models.CASCADE, null=True, blank=True)
category = models.ForeignKey(Category, on_delete=models.CASCADE, null=True, blank=True)
location = models.CharField(max_length=200)
salary = models.CharField(max_length=100)
uniqueId = models.CharField(null=True, blank=True, max_length=100 )
type = models.CharField(max_length=10,choices =TYPE_CHOICES, default=FULL_TIME,null=True, blank=True,)
experience = models.CharField(max_length=10,choices = EXP_CHOICES, default = TIER1)
summary = models.TextField(null=True, blank=True)
description = models.TextField(null=True, blank=True)
requirements = models.TextField(null=True, blank=True)
duties = models.TextField(null=True, blank=True)
enquires = models.TextField(null=True, blank=True)
applications =models.TextField(null=True, blank=True)
note = models.TextField(null=True, blank=True)
closing_date = models.DateField(null=True, blank=True)
#logo = models.ImageField(default = 'default.png', upload_to = 'upload_imges')
date_posted = models.DateTimeField(default=timezone.now)
owner = models.ForeignKey(User, on_delete=models.CASCADE)
contract_type = models.CharField(max_length=100, null= True, blank=True)
slug = models.SlugField(max_length=500, unique=True, blank=True, null=True)
seoDescription = models.CharField(max_length=500, null=True, blank=True)
seoKeywords = models.CharField(max_length=500, null=True, blank=True)
urlLink = models.CharField(max_length=500, null=True, blank=True)
def _str_(self):
return '{} - {} - {}'.format(self.company, self.title, self.location)
def get_absolute_url(self):
return reverse('job-detail', kwargs={'slug': self.slug})
def save(self, *args, **kwargs):
if self.uniqueId is None:
self.uniqueId = str(uuid4()).split('-')[0]
self.slug = slugify('{} {} {} {}'.format('{} {} {}'.format(self.company, self.title, self.location, self.uniqueId)))
self.slug = slugify('{} {} {} {}'.format('{} {} {}'.format(self.company, self.title, self.location, self.uniqueId)))
self.seoKeywords = 'Careers Portal, Online job application, full time jobs, part time jobs, get a job, apply for a job, {}, {}'.format(self.company.title, self.title)
self.seoDescription = '{}'.format('Careers Portal {} Jo application. Apply for job: {} in {}, online today'.format(self.company.title, self.title, self.location))
super(Jobs, self).save(*args, **kwargs)
What I have tried:
I can not find a definitive solution to this problem which can help