All tests fail with TypeError: isinstance() arg 2 must be a type or tuple of types

1,124 views
Skip to first unread message

Sceva

unread,
Jun 17, 2014, 12:52:28 PM6/17/14
to django...@googlegroups.com
The full error (last on in the stack) is 

File "/home//venv/lib/python3.3/site-packages/django/db/models/fields/related.py", line 1699, in get_default
    if isinstance(field_default, self.rel.to):
TypeError: isinstance() arg 2 must be a type or tuple of types

Python 3.3.2, Django 1.7b1

If I switch to 1.7b4, the error changes to 

  File "/home/s/Pycharm/flf/venv/lib/python3.3/site-packages/django/db/migrations/state.py", line 86, in render
    model=lookup_model,
ValueError: Lookup failed for model referenced by field study.Card.image: studyimages.StudyImage

The error occurs when I create a FK field to a model in another app:
study/models.py:
....
    image = models.ForeignKey('studyimages.StudyImage', default=None, blank=True, null=True, related_name='cardpic')

The initial problem occurred with migrate, which I overcame by changing the fk model to one in the same app, migrating, then changing the fk back to the above the migrate command is successful.

I can run my unittests using django 1.6.5, and my functional tests may run if I stop using StaticLiveServerCase.

I have seen several bugs about migrated and unmigrated apps not able to use FKs, but both of my apps have migrations before introducing the FK.  Thanks in advance.

Sceva

unread,
Jun 17, 2014, 12:57:05 PM6/17/14
to django...@googlegroups.com
The error appears when I run tests and it is trying to create the default database. 

I forgot to add that I found this, https://github.com/pelme/pytest_django/issues/68 that seems to be a similar issue.

Sceva

unread,
Jun 18, 2014, 2:57:19 PM6/18/14
to django...@googlegroups.com
Deleted all the migration files, re-ran makemigrations and migrate, and errors disappeared.

Reply all
Reply to author
Forward
0 new messages