Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

column <column> does not exist (Django 1.8)

I am trying to interact with the development server for my django project. However any page on the server returns the same error:

Exception Type: ProgrammingError

Exception Value: column myApp_verb.date does not exist

I had not recently added the field date to the model verb (it's been there for a while, and I'm not sure what caused this error to begin). My collaborators all have identical files on their local machines, and none of them are having any issues.

I have tried various things:

I have tried removing the date field (and all references to it). makemigrations did not detect any changes, and migrate failed with error:

django.db.utils.ProgrammingError: column "date" does not exist

I have tried renaming the field. Once again makemigrations did not detect any changes, and migrate failed with the same error as above.

I have tried deleting all of my migrations. This changed nothing.

I'm out of ideas at this point. Any help would be much appreciated.

Thanks in advance!

Edit: Here is the verb class, as requested. Its pretty simple:

class Verb(models.Model):
    english_gloss = models.CharField(max_length = 20)
    first_person = models.CharField(max_length = 20)
    second_person = models.CharField(max_length = 20)
    third_person = models.CharField(max_length = 20)
    fourth_person = models.CharField(max_length = 20)
    transitivity = models.BooleanField()
    classifier = models.CharField(max_length = 20)
    inner_lexical = models.CharField(max_length = 20)
    outer_lexical = models.CharField(max_length = 20)
    perfective = models.CharField(max_length = 20)
    imperfective = models.CharField(max_length = 20)
    date = models.DateTimeField(auto_now_add = True)
like image 245
acrane Avatar asked Mar 16 '23 14:03

acrane


1 Answers

You can create a manual migration to fix the issue.

First comment out the coloumn(s) that are throwing the error.

Then write the manual migration. Usually something like this:

# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models    

class Migration(migrations.Migration):   

    dependencies = [
        ('my_field', 'last_migration_filename'), # no .py
    ]        

    operations = [
        migrations.AddField(
            model_name='my_model',
            name='my_field',
            field=models.MyField(blank=True, null=True),
        ),
    ]

Then run python manage.py migrate. It will create that/those field(s).

Afterwards, uncomment the fields that cause the errors.

Worked for me like a charm.

like image 144
Özer Avatar answered Mar 27 '23 03:03

Özer