Django 1.7 Django.db.utils.OperationalError:没有这样的表:auth_customuser

Django 1.7 Django.db.utils.OperationalError:没有这样的表:auth_customuser,django,testing,Django,Testing,使用新的迁移将大型1.6项目迁移到1.7,这是一项艰巨的任务。我现在可以使用makemigrations和migrate重新创建数据库,但是当我尝试运行测试时,我遇到了关于auth_customuser的错误。我正在使用一个自定义用户,但它在我的web应用程序中,而不是customuser 以下是运行测试的输出,其中包含一些打印语句,以尝试了解发生了什么: (gmd)iMacs-iMac:gmdz phoebebr$ python manage.py test web -v 3 Creatin

使用新的迁移将大型1.6项目迁移到1.7,这是一项艰巨的任务。我现在可以使用makemigrations和migrate重新创建数据库,但是当我尝试运行测试时,我遇到了关于auth_customuser的错误。我正在使用一个自定义用户,但它在我的web应用程序中,而不是customuser

以下是运行测试的输出,其中包含一些打印语句,以尝试了解发生了什么:

(gmd)iMacs-iMac:gmdz phoebebr$ python manage.py test web -v 3

Creating test database for alias 'default' (':gmd_test_db:')...
Destroying old test database 'default'...
Type 'yes' if you would like to try deleting the test database ':gmd_test_db:', or 'no' to cancel: yes
starting results iter loop
Operations to perform:
  Synchronize unmigrated apps: json_field, ipn, registration
  Apply all migrations: web, sessions, admin, sites, auth, tastypie, contenttypes, taggit
Synchronizing apps without migrations:
Running pre-migrate handlers for application auth
Running pre-migrate handlers for application contenttypes
Running pre-migrate handlers for application sessions
Running pre-migrate handlers for application sites
Running pre-migrate handlers for application admin
Running pre-migrate handlers for application taggit
Running pre-migrate handlers for application web
Running pre-migrate handlers for application json_field
Running pre-migrate handlers for application registration
Running pre-migrate handlers for application tastypie
Running pre-migrate handlers for application ipn
  Creating tables...
    Creating table registration_registrationprofile
    Creating table paypal_ipn
  Installing custom SQL...
  Installing indexes...
    Installing index for ipn.PayPalIPN model
Loading 'initial_data' fixtures...
Checking '/Users/phoebebr/Development/gmdz/web/fixtures' for fixtures...
No fixture 'initial_data' in '/Users/phoebebr/Development/gmdz/web/fixtures'.
Checking '/Users/phoebebr/Development/gmdz' for fixtures...
No fixture 'initial_data' in '/Users/phoebebr/Development/gmdz'.
Loading 'initial_data' fixtures...
Checking '/Users/phoebebr/Development/gmdz/web/fixtures' for fixtures...
No fixture 'initial_data' in '/Users/phoebebr/Development/gmdz/web/fixtures'.
Checking '/Users/phoebebr/Development/gmdz' for fixtures...
No fixture 'initial_data' in '/Users/phoebebr/Development/gmdz'.
Loading 'initial_data' fixtures...
Checking '/Users/phoebebr/Development/gmdz/web/fixtures' for fixtures...
No fixture 'initial_data' in '/Users/phoebebr/Development/gmdz/web/fixtures'.
Checking '/Users/phoebebr/Development/gmdz' for fixtures...
No fixture 'initial_data' in '/Users/phoebebr/Development/gmdz'.
Installed 0 object(s) from 0 fixture(s)
Running migrations:
  Applying contenttypes.0001_initial... OK
  Applying auth.0001_initial... OK
  Applying web.0001_initial... OK
  Applying admin.0001_initial... OK
  Applying sessions.0001_initial... OK
  Applying sites.0001_initial... OK
  Applying taggit.0001_initial... OK
  Applying tastypie.0001_initial... OK
Running post-migrate handlers for application auth

看虚拟电视

(gmd)$ grep -r "customuser" *
lib/python2.7/site-packages/django/contrib/auth/fixtures/custom_user.json:        "model": "auth.customuser",
lib/python2.7/site-packages/django/contrib/auth/tests/test_decorators.py:        # Add permissions auth.add_customuser and auth.change_customuser
lib/python2.7/site-packages/django/contrib/auth/tests/test_decorators.py:        perms = models.Permission.objects.filter(codename__in=('add_customuser', 'change_customuser'))
lib/python2.7/site-packages/django/contrib/auth/tests/test_decorators.py:        @permission_required(['auth.add_customuser', 'auth.change_customuser'])
lib/python2.7/site-packages/django/contrib/auth/tests/test_decorators.py:        @permission_required('auth.add_customuser')
lib/python2.7/site-packages/django/contrib/auth/tests/test_decorators.py:        @permission_required(['auth.add_customuser', 'auth.change_customuser', 'non-existent-permission'])
lib/python2.7/site-packages/django/contrib/auth/tests/test_decorators.py:        @permission_required(['auth.add_customuser', 'auth.change_customuser', 'non-existent-permission'], raise_exception=True)
Binary file lib/python2.7/site-packages/django/contrib/auth/tests/test_decorators.pyc matches
因此,在require_权限装饰器中添加一些跟踪,但它从未被触发,正如我在测试套件中所期望的那样

所以我现在已经没有主意了。这一定是我的问题,因为没有其他人报告过这个错误,我只是不知道该去哪里找

要求:

Django==1.7.1
MySQL-python==1.2.5
Pillow==2.6.1
South==1.0.1
Unidecode==0.04.16
argparse==1.2.1
django-crontab==0.6.0
django-facebook==6.0.2
django-google-maps==0.2.3
django-nose==1.3
django-paypal==0.1.5
django-taggit==0.12.2
django-tastypie==0.12.1
jsonfield==1.0.0
mock==1.0.1
nose==1.3.4
python-dateutil==2.3
python-mimeparse==0.1.4
pytz==2014.10
qrcode==5.1
requests==2.5.0
six==1.8.0
wsgiref==0.1.2
在项目中也有以下应用程序,因为它们有次要的tweek

lazysignup
django-registration

我认为答案如下:

看起来您在项目中有一个自己的应用程序名为
auth
,这与上面的票证中提到的
django.contrib.auth
相冲突,应用程序路径的最后一段,即
auth
必须在项目中使用的所有应用程序(包括django自己的应用程序)中都是唯一的

因此,当您运行测试时,Django会发现fixture
Django/contrib/auth/fixtures/custom_user.json
(Django附带)。但它会感到困惑,并尝试根据
auth
应用程序的模型而不是
django.contrib.auth
模型加载它


您应该将您的
auth
应用程序重命名为唯一的应用程序。

django 1.7.x的完整版本?您可以分享您的需求(包、版本和/或github url)django 1.7.1和添加的需求吗?看起来在您的测试夹具中,您有一个“auth_customuser”表——它可能是旧的cruft或其他东西。你能重新创建你的测试夹具JSON文件而不转储auth表吗?你在
安装的应用程序中有什么?不完全是,但几乎是。出于某种早已被遗忘的原因,在测试套件中发现了这条流氓线路。从django.contrib.auth.tests.custom_user导入CustomUser Phew现在它又能工作了!
Django==1.7.1
MySQL-python==1.2.5
Pillow==2.6.1
South==1.0.1
Unidecode==0.04.16
argparse==1.2.1
django-crontab==0.6.0
django-facebook==6.0.2
django-google-maps==0.2.3
django-nose==1.3
django-paypal==0.1.5
django-taggit==0.12.2
django-tastypie==0.12.1
jsonfield==1.0.0
mock==1.0.1
nose==1.3.4
python-dateutil==2.3
python-mimeparse==0.1.4
pytz==2014.10
qrcode==5.1
requests==2.5.0
six==1.8.0
wsgiref==0.1.2
lazysignup
django-registration