{"action":"created","issue":{"url":"https://api.github.com/repos/divio/django-cms/issues/3891","labels_url":"https://api.github.com/repos/divio/django-cms/issues/3891/labels{/name}","comments_url":"https://api.github.com/repos/divio/django-cms/issues/3891/comments","events_url":"https://api.github.com/repos/divio/django-cms/issues/3891/events","html_url":"https://github.com/divio/django-cms/issues/3891","id":58495252,"number":3891,"title":"db_table error in Django 1.7 on sqlite","user":{"login":"yakky","id":714711,"avatar_url":"https://avatars.githubusercontent.com/u/714711?v=3","gravatar_id":"","url":"https://api.github.com/users/yakky","html_url":"https://github.com/yakky","followers_url":"https://api.github.com/users/yakky/followers","following_url":"https://api.github.com/users/yakky/following{/other_user}","gists_url":"https://api.github.com/users/yakky/gists{/gist_id}","starred_url":"https://api.github.com/users/yakky/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yakky/subscriptions","organizations_url":"https://api.github.com/users/yakky/orgs","repos_url":"https://api.github.com/users/yakky/repos","events_url":"https://api.github.com/users/yakky/events{/privacy}","received_events_url":"https://api.github.com/users/yakky/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/divio/django-cms/labels/blocker","name":"blocker","color":"eb6420"},{"url":"https://api.github.com/repos/divio/django-cms/labels/kind:%20bug","name":"kind: bug","color":"c7def8"}],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/divio/django-cms/milestones/30","labels_url":"https://api.github.com/repos/divio/django-cms/milestones/30/labels","id":988866,"number":30,"title":"3.0.11","description":"","creator":{"login":"mkoistinen","id":615759,"avatar_url":"https://avatars.githubusercontent.com/u/615759?v=3","gravatar_id":"","url":"https://api.github.com/users/mkoistinen","html_url":"https://github.com/mkoistinen","followers_url":"https://api.github.com/users/mkoistinen/followers","following_url":"https://api.github.com/users/mkoistinen/following{/other_user}","gists_url":"https://api.github.com/users/mkoistinen/gists{/gist_id}","starred_url":"https://api.github.com/users/mkoistinen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mkoistinen/subscriptions","organizations_url":"https://api.github.com/users/mkoistinen/orgs","repos_url":"https://api.github.com/users/mkoistinen/repos","events_url":"https://api.github.com/users/mkoistinen/events{/privacy}","received_events_url":"https://api.github.com/users/mkoistinen/received_events","type":"User","site_admin":false},"open_issues":5,"closed_issues":3,"state":"open","created_at":"2015-02-20T21:01:47Z","updated_at":"2015-02-22T08:50:54Z","due_on":"2015-02-28T05:00:00Z","closed_at":null},"comments":4,"created_at":"2015-02-22T08:26:41Z","updated_at":"2015-02-22T17:06:48Z","closed_at":null,"body":"sqlite backend in Dajngo 1.7 implements some migrations by applying them to a temporary model with a patched db_table name and then renaming the new table (https://github.com/django/django/blob/stable/1.7.x/django/db/backends/sqlite3/schema.py#L124-L154)\r\n``PlacheolderField`` defines a ``contribute_to_class`` method (https://github.com/divio/django-cms/blob/develop/cms/models/fields.py#L70-L78) with some custom logic  (but that's also true for any ``ForeignKey``).\r\nBeing part of the database schema ``contribute_to_class`` is called during migrations process::\r\n\r\n        failures = test_runner.run_tests(test_labels)\r\n    File \"/var/local/venvs/cms-3.1-py3/lib/python3.4/site-packages/django/test/runner.py\", line 147, in run_tests\r\n        old_config = self.setup_databases()\r\n    File \"/var/local/venvs/cms-3.1-py3/lib/python3.4/site-packages/django/test/runner.py\", line 109, in setup_databases\r\n        return setup_databases(self.verbosity, self.interactive, **kwargs)\r\n    File \"/var/local/venvs/cms-3.1-py3/lib/python3.4/site-packages/django/test/runner.py\", line 299, in setup_databases\r\n        serialize=connection.settings_dict.get(\"TEST\", {}).get(\"SERIALIZE\", True),\r\n    File \"/var/local/venvs/cms-3.1-py3/lib/python3.4/site-packages/django/db/backends/creation.py\", line 377, in create_test_db\r\n        test_flush=True,\r\n    File \"/var/local/venvs/cms-3.1-py3/lib/python3.4/site-packages/django/core/management/__init__.py\", line 115, in call_command\r\n        return klass.execute(*args, **defaults)\r\n    File \"/var/local/venvs/cms-3.1-py3/lib/python3.4/site-packages/django/core/management/base.py\", line 338, in execute\r\n        output = self.handle(*args, **options)\r\n    File \"/var/local/venvs/cms-3.1-py3/lib/python3.4/site-packages/django/core/management/commands/migrate.py\", line 161, in handle\r\n        executor.migrate(targets, plan, fake=options.get(\"fake\", False))\r\n    File \"/var/local/venvs/cms-3.1-py3/lib/python3.4/site-packages/django/db/migrations/executor.py\", line 68, in migrate\r\n        self.apply_migration(migration, fake=fake)\r\n    File \"/var/local/venvs/cms-3.1-py3/lib/python3.4/site-packages/django/db/migrations/executor.py\", line 102, in apply_migration\r\n        migration.apply(project_state, schema_editor)\r\n    File \"/var/local/venvs/cms-3.1-py3/lib/python3.4/site-packages/django/db/migrations/migration.py\", line 108, in apply\r\n        operation.database_forwards(self.app_label, schema_editor, project_state, new_state)\r\n    File \"/var/local/venvs/cms-3.1-py3/lib/python3.4/site-packages/django/db/migrations/operations/fields.py\", line 37, in database_forwards\r\n        field,\r\n    File \"/var/local/venvs/cms-3.1-py3/lib/python3.4/site-packages/django/db/backends/sqlite3/schema.py\", line 176, in add_field\r\n        self._remake_table(model, create_fields=[field])\r\n    File \"/var/local/venvs/cms-3.1-py3/lib/python3.4/site-packages/django/db/backends/sqlite3/schema.py\", line 133, in _remake_table\r\n        temp_model = type(model._meta.object_name, model.__bases__, body)\r\n    File \"/var/local/venvs/cms-3.1-py3/lib/python3.4/site-packages/django/db/models/base.py\", line 168, in __new__\r\n        new_class.add_to_class(obj_name, obj)\r\n    File \"/var/local/venvs/cms-3.1-py3/lib/python3.4/site-packages/django/db/models/base.py\", line 297, in add_to_class\r\n        value.contribute_to_class(cls, name)\r\n    File \"/srv/repo/django-cms-3.0/cms/models/fields.py\", line 76, in contribute_to_class\r\n        super(PlaceholderField, self).contribute_to_class(cls, name)\r\n\r\nIf the migration for the model definining a ``PlaceholderField`` instance which calls ``_remake_table`` is the last one in the series, the patched db_table is preserved and leaks in the ``PlaceholderField`` accessor for that model, resulting in silent errors when trying to access the accessor itself (in https://github.com/divio/django-cms/blob/develop/cms/models/placeholdermodel.py#L158 and https://github.com/divio/django-cms/blob/develop/cms/models/placeholdermodel.py#L180)\r\n\r\nFrom my investigation there is nothing wrong in the CMS code, but a workaround has to be applied in our codebase while trying to reproduce and submit the issue to Django."},"comment":{"url":"https://api.github.com/repos/divio/django-cms/issues/comments/75445305","html_url":"https://github.com/divio/django-cms/issues/3891#issuecomment-75445305","issue_url":"https://api.github.com/repos/divio/django-cms/issues/3891","id":75445305,"user":{"login":"yakky","id":714711,"avatar_url":"https://avatars.githubusercontent.com/u/714711?v=3","gravatar_id":"","url":"https://api.github.com/users/yakky","html_url":"https://github.com/yakky","followers_url":"https://api.github.com/users/yakky/followers","following_url":"https://api.github.com/users/yakky/following{/other_user}","gists_url":"https://api.github.com/users/yakky/gists{/gist_id}","starred_url":"https://api.github.com/users/yakky/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yakky/subscriptions","organizations_url":"https://api.github.com/users/yakky/orgs","repos_url":"https://api.github.com/users/yakky/repos","events_url":"https://api.github.com/users/yakky/events{/privacy}","received_events_url":"https://api.github.com/users/yakky/received_events","type":"User","site_admin":false},"created_at":"2015-02-22T17:06:48Z","updated_at":"2015-02-22T17:06:48Z","body":"Test case an fix pushed"}}