Column <column> does not exist (Django 1.8)
I am trying to interact with a 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 have not recently added a field date to the model verb (it has been there for a while, and I'm not sure what caused this error). My collaborators have the same files on their local machines, and none of them have any problems.
I tried different things:
I tried to remove the date field (and all references to it). makemigrationsdid not find any changes, but migrateended with an error:
django.db.utils.ProgrammingError: column "date" does not exist
I tried to rename the field. Once again, I makemigrationsdid not find any changes and could not complete the migration with the same error as above.
I tried to delete all my migrations. This has not changed anything.
. .
!
: , . :
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)
, .
coloumn (s), .
. - :
# -*- 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),
),
]
python manage.py migrate. / .
, .
.
Özer S. , . Django, Django , ? , , !
- :
models.py :
TEMPLATE = ( ('list', 'List'), ('table', 'Table') ) template = models.CharField( 'View template', choices=TEMPLATE, max_length=7, default='list' ), . "" "blogcategory" "", "0005_template".
(0005_template.py):
# -*- coding: utf-8 -*- from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('blog', '0004_auto_20170628_1533'), ] operations = [ migrations.AddField( model_name='blogcategory', name='template', field=models.CharField( verbose_name='View template', choices=[('list', 'List'), ('table', 'Table')], max_length=7, default='list' ), ), ], :
TEMPLATE = ( ('list', 'List'), ('table', 'Table') ) template = models.CharField( 'View template', choices=TEMPLATE, max_length=7, default='list' ):
python manage.py migrate blogOperations to perform: Apply all migrations: blog Running migrations: Applying blog.0005_template... OK
As a result, the "template" field with the standard "list" was added to all entries in the "blogcategory" table.
PS Do not forget to uncomment the field in the model.
I had this problem. I fixed this by going to the Django migration table in the database and finding the migration failed. In my case, it was a fairly recent migration. I deleted this migration and others following it. Then try again python manage.py makemigrationsand python manage.py migrate. This time both teams started and the error disappeared.