python - Django ORM Array Field Error -
i got error when trying run migrate command
file "/usr/local/lib/python3.4/dist-packages/django/db/backends/utils.py", line 64, in execute return self.cursor.execute(sql, params) psycopg2.programmingerror: operator class "varchar_pattern_ops" not accept data type character varying[]
i have arrayfield in model. when removed arrayfield, worked fine
i'm using django 1.8, python 3.4 , postgresql 9.4
models
from django.db import models django.contrib.postgres.fields import arrayfield django.contrib.auth.models import user class post(models.model): author = models.foreignkey(user) title = models.charfield(max_length=512) slug = models.slugfield(unique=true, db_index=true) summary = models.textfield(blank=true, null=true) content = models.textfield() tags = arrayfield(models.charfield(max_length=256), blank=true, db_index=true) is_published = models.booleanfield(default=true) has_comments = models.booleanfield(default=true) created_on = models.datetimefield(auto_now_add=true) updated_on = models.datetimefield(auto_now=true) def __str__(self): return self.title class comment(models.model): post = models.foreignkey(post, db_index=true) name = models.charfield(max_length=256) email = models.emailfield() content = models.textfield() is_published = models.booleanfield(default=false) created_on = models.datetimefield(auto_now_add=true) updated_on = models.datetimefield(auto_now=true) def __str__(self): return self.name
migrations
from __future__ import unicode_literals django.db import models, migrations import django.contrib.postgres.fields django.conf import settings class migration(migrations.migration): dependencies = [ migrations.swappable_dependency(settings.auth_user_model), ] operations = [ migrations.createmodel( name='comment', fields=[ ('id', models.autofield(verbose_name='id', serialize=false, auto_created=true, primary_key=true)), ('name', models.charfield(max_length=256)), ('email', models.emailfield(max_length=254)), ('content', models.textfield()), ('is_published', models.booleanfield(default=false)), ('created_on', models.datetimefield(auto_now_add=true)), ('updated_on', models.datetimefield(auto_now=true)), ], ), migrations.createmodel( name='post', fields=[ ('id', models.autofield(verbose_name='id', serialize=false, auto_created=true, primary_key=true)), ('title', models.charfield(max_length=512)), ('slug', models.slugfield(unique=true)), ('summary', models.textfield(null=true, blank=true)), ('content', models.textfield()), ('tags', django.contrib.postgres.fields.arrayfield(blank=true, size=none, base_field=models.charfield(max_length=256), db_index=true)), ('is_published', models.booleanfield(default=true)), ('has_comments', models.booleanfield(default=true)), ('created_on', models.datetimefield(auto_now_add=true)), ('updated_on', models.datetimefield(auto_now=true)), ('author', models.foreignkey(to=settings.auth_user_model)), ], ), migrations.addfield( model_name='comment', name='post', field=models.foreignkey(to='posts.post'), ), ]
Comments
Post a Comment