Closed jantoniomartin closed 9 years ago
Adding ('contenttypes', '__first__')
as a dependency to the migration seems to solve this problem, but then a different exception is thrown:
ValueError: Lookup failed for model referenced by field notifications.NoticeSetting.user: auth.User
If I add ('auth', '__first__')
as a dependency, then the error is:
django.db.utils.OperationalError: (1005, 'Can\'t create table `app_dev`.`#sql-903_12fd` (errno: 150 "Foreign key constraint is incorrectly formed")')
I can confirm that this problem is the same with Django-1.7.9.dev20150528142627.
I have found a workaround for this problem:
In the migration 0001_initial.py
, add only ('auth', '__first__')
as a dependency.
I could send a pull request, but I don't know if manually editing the migration is appropriate.
Would be great to get this into pypi, I've had to downgrade to 2.0.1 to continue to be able to migrate.
How about pypi bugfix release?
Pushed 3.0.0 to PyPI. There are some minor changes from 2.1.0 to 3.0.0 but it drops support for Python 2.6 and Django 1.6 so I think it warranted a major release.
We're seeing issues still with 3.0.x on Django 1.7.x. I'm having my teammate comment on the solution shortly.
This is still a problem after upgrading to 3.0.0. Adding ('contenttypes', '0001_initial') as a dependency after line 13 in 0001_initial.py is still necessary to proceed without the error. (The file generated by deleting the original 0001_initial.py and running makemigrate in django 1.7.9 also includes that dependency.)
Per @peterfarrell, this pull request for django-cms uses ('contenttypes', 'latest') to address the issue in their code, which eliminates the need for logic to handle the django version:
dependencies = [
('cms', '0009_merge'),
('contenttypes', '__latest__'),
]
Until a change is made to address this, this ticket should be re-opened.
+1 on least breakage prone solution to use __latest__
instead of version checking.
upgraded to version 3.0.0 and i am getting with Django 1.7.9 :
Running migrations:
Applying notifications.0001_initial...Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/home/vagrant/.virtualenvs/xxx/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 385, in execute_from_command_line
utility.execute()
File "/home/vagrant/.virtualenvs/xxx/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 377, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/vagrant/.virtualenvs/xxx/local/lib/python2.7/site-packages/django/core/management/base.py", line 288, in run_from_argv
self.execute(*args, **options.__dict__)
File "/home/vagrant/.virtualenvs/xxx/local/lib/python2.7/site-packages/django/core/management/base.py", line 338, in execute
output = self.handle(*args, **options)
File "/home/vagrant/.virtualenvs/xxx/local/lib/python2.7/site-packages/django/core/management/commands/migrate.py", line 161, in handle
executor.migrate(targets, plan, fake=options.get("fake", False))
File "/home/vagrant/.virtualenvs/xxx/local/lib/python2.7/site-packages/django/db/migrations/executor.py", line 68, in migrate
self.apply_migration(migration, fake=fake)
File "/home/vagrant/.virtualenvs/xxx/local/lib/python2.7/site-packages/django/db/migrations/executor.py", line 96, in apply_migration
if self.detect_soft_applied(migration):
File "/home/vagrant/.virtualenvs/xxx/local/lib/python2.7/site-packages/django/db/migrations/executor.py", line 140, in detect_soft_applied
apps = project_state.render()
File "/home/vagrant/.virtualenvs/xxx/local/lib/python2.7/site-packages/django/db/migrations/state.py", line 94, in render
raise ValueError(msg.format(field=operations[0][1], model=lookup_model))
ValueError: Lookup failed for model referenced by field notifications.NoticeSetting.scoping_content_type: contenttypes.ContentType
When running
python manage.py migrate
with Django-1.7.8, an exception is thrown and the migration fails. The relevant part of the traceback is this: