This problem is driving me nuts - I can't spot what's going on so I was hoping that someone would be able to point out what I'm missing here.
I've got two sample models, FootballClub, FootballPitch, as defined below.
class FootballClub(models.Model)
name = models.CharField(max_length=100)
class Meta:
ordering = ['name']
def __unicode__(self):
return self.name
class FootballPitch(models.Model):
name = models.CharField(max_length=100)
owning_club = models.ForeignKey(FootballClub)
I've made a modification to the FootballPitch
class, more specifically the owning_club
field, to add null=True
to it, so the class now looks like this;
class FootballPitch(models.Model):
name = models.CharField(max_length=100)
owning_club = models.ForeignKey(FootballClub, null=True)
(I don't need to manage this model through a form so I don't care that blank=True
is not set).
I have also run makemigrations
and migrate
on this model.
When trying to list out all instances of FootballPitch
that have owning_club
set to null (using FootballPitch.objects.filter(owning_club__isnull=True)
) I get the following error;
Programming Error: relation "footballclub_footballpitch" does not exist
LINE 1: ...d", "footballclub_footballpitch"."name",FROM "footballclub_f...
Anyone have any ideas what is going wrong? (Django 1.8.18 and Python 2.7 and postgres 9.8 for reference)
Thanks in advance!
Edit: Due to request added migrations code here instead of in reply to comment requesting it;
./manage.py --list outputs the following;
[X] 0001_initial [X] 0002_auto_20191009_1409
The migration contains # -- coding: utf-8 -- from future import unicode_literals from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('football', '0001_initial'), ] operations = [ migrations.AlterField( model_name='footballpitch', name='owning_club', field=models.ForeignKey(to='football.FootballClub', null=True), ), ]
Edit++ to include initial migration
from __future__ import unicode_literals
from django.db import migrations, models
import django.utils.timezone
import django_extensions.db.fields
class Migration(migrations.Migration):
dependencies = [
]
operations = [
migrations.CreateModel(
name='FootballClub',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('name', models.CharField(max_length=100)),
],
options={
'ordering': ['name'],
},
),
migrations.CreateModel(
name='FootballPitch',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('name', models.CharField(max_length=100)),
('owning_club', models.ForeignKey(to='football.FootballClub')),
],
),
]```