#25832: Migrating a django-cms.PlaceholderField fails when using Postgres
----------------------------------------------+--------------------
Reporter: jribbens | Owner: nobody
Type: Bug | Status: new
Component: Database layer (models, ORM) | Version: 1.8
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
----------------------------------------------+--------------------
It seems to me that 'makemigrations' creating broken migrations is a bug.
The django-cms people say it is a django bug not a django-cms bug, hence
my ticket here (see https://github.com/divio/django-cms/issues/4789 ).
{{{
$ pip install djangocms-installer psycopg2
$ djangocms -sqp . -d postgresql://test:test@localhost/test my_demo
$ python manage.py startapp testapp
}}}
Add testapp as penultimate entry in my_demo/settings.py:INSTALLED_APPS.
Edit testapp/models.py:
{{{#!python
from django.db import models
class TestModel(models.Model):
description = models.TextField("Description")
}}}
{{{
$ python manage.py makemigrations testapp
$ python manage.py migrate
}}}
Edit testapp/models.py:
{{{#!python
from django.db import models
from cms.models.fields import PlaceholderField
class TestModel(models.Model):
description = PlaceholderField("Description")
}}}
{{{
$ python manage.py makemigrations testapp
$ python manage.py migrate
...
Running migrations:
Rendering model states... DONE
Applying testapp.0002_auto_20151129_1448...Traceback (most recent call
last):
File "test/env/lib/python3.4/site-packages/django/db/backends/utils.py",
line 64, in execute
return self.cursor.execute(sql, params)
psycopg2.ProgrammingError: column "description_id" cannot be cast
automatically to type integer
HINT: You might need to specify "USING description_id::integer".
}}}
This only happens with Postgres (or rather, it doesn't happen with sqlite,
i.e. if you remove the -d from the djangocms invocation above). It only
happens if the column is being changed in one migration, if it's split
into two migrations the first of which deletes the column and the second
of which creates it, there is no issue.
I was originally actually getting "ValueError: Related model
'cms.Placeholder' cannot be resolved", but I cannot reproduce that so
easily since I already fixed it in my project - see mailing list thread
https://groups.google.com/forum/#!topic/django-cms/tIT3g0gCpwc.
--
Ticket URL: <https://code.djangoproject.com/ticket/25832>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/051.4179d91c7625f5789d3ef3445d94aa19%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.