django-registration 1.0 与 Django 1.6 和 Python 3.3.4

django-registration 1.0 with Django 1.6 and Python 3.3.4

我正在尝试使用 django-registration 1.0 将名为 course 的 web 应用程序从 Django 1.4 升级到 1.6。其他 django-registration 线程似乎都没有与此问题相关的任何内容。

我正在通过 python manage.py 测试课程运行单元测试,该课程崩溃并出现以下跟踪:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
> /home/chris/.virtualenvs/blanket/lib/python3.3/site-packages/django/db/transaction.py(449)commit_on_success()
-> warnings.warn("commit_on_success is deprecated in favor of atomic.",
(Pdb) c
Traceback (most recent call last):
  File"manage.py", line 11, in <module>
    execute_from_command_line(sys.argv)
  File"/home/chris/.virtualenvs/blanket/lib/python3.3/site-packages/django/core/management/__init__.py", line 399, in execute_from_command_line
    utility.execute()
  File"/home/chris/.virtualenvs/blanket/lib/python3.3/site-packages/django/core/management/__init__.py", line 392, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File"/home/chris/.virtualenvs/blanket/lib/python3.3/site-packages/django/core/management/commands/test.py", line 50, in run_from_argv
    super(Command, self).run_from_argv(argv)
  File"/home/chris/.virtualenvs/blanket/lib/python3.3/site-packages/django/core/management/base.py", line 242, in run_from_argv
    self.execute(*args, **options.__dict__)
  File"/home/chris/.virtualenvs/blanket/lib/python3.3/site-packages/django/core/management/commands/test.py", line 71, in execute
    super(Command, self).execute(*args, **options)
  File"/home/chris/.virtualenvs/blanket/lib/python3.3/site-packages/django/core/management/base.py", line 285, in execute
    output = self.handle(*args, **options)
  File"/home/chris/.virtualenvs/blanket/lib/python3.3/site-packages/django/core/management/commands/test.py", line 88, in handle
    failures = test_runner.run_tests(test_labels)
  File"/home/chris/.virtualenvs/blanket/lib/python3.3/site-packages/django/test/runner.py", line 145, in run_tests
    old_config = self.setup_databases()
  File"/home/chris/.virtualenvs/blanket/lib/python3.3/site-packages/django/test/runner.py", line 107, in setup_databases
    return setup_databases(self.verbosity, self.interactive, **kwargs)
  File"/home/chris/.virtualenvs/blanket/lib/python3.3/site-packages/django/test/runner.py", line 279, in setup_databases
    verbosity, autoclobber=not interactive)
  File"/home/chris/.virtualenvs/blanket/lib/python3.3/site-packages/django/db/backends/creation.py", line 339, in create_test_db
    load_initial_data=False)
  File"/home/chris/.virtualenvs/blanket/lib/python3.3/site-packages/django/core/management/__init__.py", line 159, in call_command
    return klass.execute(*args, **defaults)
  File"/home/chris/.virtualenvs/blanket/lib/python3.3/site-packages/django/core/management/base.py", line 284, in execute
    self.validate()
  File"/home/chris/.virtualenvs/blanket/lib/python3.3/site-packages/django/core/management/base.py", line 310, in validate
    num_errors = get_validation_errors(s, app)
  File"/home/chris/.virtualenvs/blanket/lib/python3.3/site-packages/django/core/management/validation.py", line 34, in get_validation_errors
    for (app_name, error) in get_app_errors().items():
  File"/home/chris/.virtualenvs/blanket/lib/python3.3/site-packages/django/db/models/loading.py", line 196, in get_app_errors
    self._populate()
  File"/home/chris/.virtualenvs/blanket/lib/python3.3/site-packages/django/db/models/loading.py", line 75, in _populate
    self.load_app(app_name, True)
  File"/home/chris/.virtualenvs/blanket/lib/python3.3/site-packages/django/db/models/loading.py", line 99, in load_app
    models = import_module('%s.models' % app_name)
  File"/home/chris/.virtualenvs/blanket/lib/python3.3/importlib/__init__.py", line 90, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File"<frozen importlib._bootstrap>", line 1584, in _gcd_import
  File"<frozen importlib._bootstrap>", line 1565, in _find_and_load
  File"<frozen importlib._bootstrap>", line 1532, in _find_and_load_unlocked
  File"<frozen importlib._bootstrap>", line 584, in _check_name_wrapper
  File"<frozen importlib._bootstrap>", line 1022, in load_module
  File"<frozen importlib._bootstrap>", line 1003, in load_module
  File"<frozen importlib._bootstrap>", line 560, in module_for_loader_wrapper
  File"<frozen importlib._bootstrap>", line 868, in _load_module
  File"<frozen importlib._bootstrap>", line 313, in _call_with_frames_removed
  File"/home/chris/.virtualenvs/blanket/lib/python3.3/site-packages/registration/models.py", line 28, in <module>
    class RegistrationManager(models.Manager):
  File"/home/chris/.virtualenvs/blanket/lib/python3.3/site-packages/registration/models.py", line 94, in RegistrationManager
    create_inactive_user = transaction.commit_on_success(create_inactive_user)
  File"/home/chris/.virtualenvs/blanket/lib/python3.3/site-packages/django/db/transaction.py", line 449, in commit_on_success
    warnings.warn("commit_on_success is deprecated in favor of atomic.",
PendingDeprecationWarning: commit_on_success is deprecated in favor of atomic.

我从 /home/chris/.virtualenvs/blanket/lib/python3.3/site-packages/django/db/transaction.py(449)commit_on_success() 进入了一个 pdb 会话。加紧两个堆栈帧,这已从 site-packages/registration/models.py(28) -> class RegistrationManager(models.Manager)

的第 28 行调用

有没有其他人尝试将 django-registration 1.0 与 Django 1.6 一起使用并看到此失败?

这里是设置/目录供参考:
base.py:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
# Django settings for EduDuck project.

import os
import django
from django.conf import global_settings

DEBUG = False

#get the path name to prepend to other settings
DJANGO_ROOT = os.path.dirname(os.path.realpath(django.__file__))

SITE_ROOT = os.path.join(os.path.dirname(__file__),
                                         os.path.pardir,
                                         os.path.pardir)

# User Profile model
AUTH_PROFILE_MODULE = 'bio.Bio'
LOGIN_REDIRECT_URL = '/courses/'

# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
TIME_ZONE = 'UTC'

# http://www.i18nguy.com/unicode/language-identifiers.html
LANGUAGE_CODE = 'en-gb'

#https://docs.djangoproject.com/en/dev/ref/contrib/sites/?from=olddocs
SITE_ID = 1

# If you set this to False, Django will make some optimizations so as not
# to load the internationalization machinery.
USE_I18N = True

# If you set this to False, Django will not format dates, numbers and
# calendars according to the current locale.
USE_L10N = True

# If you set this to False, Django will not use timezone-aware datetimes.
USE_TZ = True

# Absolute filesystem path to the directory that will hold user-uploaded files.
# Example:"/home/media/media.lawrence.com/media/"
MEDIA_ROOT = os.path.join(SITE_ROOT, 'media/')

# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash.
# Examples:"http://media.lawrence.com/media/","http://example.com/media/"
MEDIA_URL = '/media/'

# Absolute path to the directory static files should be collected to.
# Don't put anything in this directory yourself; store your static files
# in apps'"static/" subdirectories and in STATICFILES_DIRS.
# Example:"/home/media/media.lawrence.com/static/"
STATIC_ROOT = '/var/www/static/'

# URL prefix for static files.
# Example:"http://media.lawrence.com/static/"
STATIC_URL = '/static/'
# Additional locations of static files

STATICFILES_DIRS = (
    os.path.join(SITE_ROOT, 'static/'),
)

# List of finder classes that know how to find static files in
# various locations.
STATICFILES_FINDERS = (
    'django.contrib.staticfiles.finders.FileSystemFinder',
    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
#    'django.contrib.staticfiles.finders.DefaultStorageFinder',
)

# List of callables that know how to import templates from various sources.
TEMPLATE_LOADERS = (
    'django.template.loaders.filesystem.Loader',
    'django.template.loaders.app_directories.Loader',
#     'django.template.loaders.eggs.Loader',
)

TEMPLATE_CONTEXT_PROCESSORS = global_settings.TEMPLATE_CONTEXT_PROCESSORS + (
    'core.context_processors.git_branch_render',
    'core.context_processors.show_survey_link',
)

MIDDLEWARE_CLASSES = (
    'django.middleware.common.CommonMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    # Uncomment the next line for simple clickjacking protection:
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
    'core.middleware.TimezoneMiddleware',
)

ROOT_URLCONF = 'EduDuck.urls'

# Python dotted path to the WSGI application used by Django's runserver.
WSGI_APPLICATION = 'EduDuck.wsgi.application'

#TODO: Ensure templates aren't under docroot for production version
TEMPLATE_DIRS = (
    os.path.join(SITE_ROOT, 'templates'),
    # Put strings here, like"/home/html/django_templates" or"C:/www/django/templates".
    # Always use forward slashes, even on Windows.
    # Don't forget to use absolute paths, not relative paths.
)

#django-registration https://bitbucket.org/ubernostrum/django-registration
#This allows new users 7 days to activate new accounts
ACCOUNT_ACTIVATION_DAYS = 7
#Set following to False to disable registration.
REGISTRATION_OPEN = True

INSTALLED_APPS = (
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    # Uncomment the next line to enable the admin:
    'django.contrib.admin',
    # Uncomment the next line to enable admin documentation:
    # 'django.contrib.admindocs',

    #Temporarily disabling haystack - 'six' package/bundled conflict?
    #django-haystack via elasticsearch backend
    #'haystack',

    #following provides account activation via email via django-registration
    'registration',

    #eduduck apps
    'courses',
    'quiz',
    'support',
    'bio',
    'interaction',
    'outcome',
    'attachment',
)

# See http://django-haystack.readthedocs.org/en/latest/tutorial.html#simple
# and override this in staging.py and production.py
HAYSTACK_CONNECTIONS = {
    'default': {
        'ENGINE': 'haystack.backends.simple_backend.SimpleEngine',
    },
#this is only here since I can't get python manage.py to read this config (handled via wsgi)
#use via python manage.py rebuild_index --using='forcron'
    'forcron': {
        'ENGINE': 'haystack.backends.elasticsearch_backend.ElasticsearchSearchEngine',
        'URL': 'http://127.0.0.1:9200/',
        'INDEX_NAME': 'haystack',
    },
}

# See http://docs.djangoproject.com/en/dev/topics/logging for
# more details on how to customize your logging configuration.
LOGGING = {
    'version': 1,
    'disable_existing_loggers': False,
    'formatters': {
        'simple': {
            'format': '%(levelname)s %(message)s'
            },
        'standard': {
            'format' :"[%(asctime)s] %(levelname)s [%(name)s:%(lineno)s] %(message)s",
            'datefmt' :"%d/%b/%Y %H:%M:%S"
            },
        },
    'filters': {
        'require_debug_false': {
            '()': 'django.utils.log.RequireDebugFalse'
        },
#TODO uncomment when on Django 1.5
#        'require_debug_true': {
#            '()': 'django.utils.log.RequireDebugTrue'
#        }
    },
    'handlers': {
        'null': {
            'level': 'DEBUG',
            'class': 'django.utils.log.NullHandler',
        },
        'mail_admins': {
            'level': 'ERROR',
            'filters': ['require_debug_false'],
            'class': 'django.utils.log.AdminEmailHandler'
        },
        'log_file': {
            'level': 'DEBUG',
            'class': 'logging.handlers.RotatingFileHandler',
            'filename': '/tmp/eduduck.log',
            'maxBytes': 10*2**20, #10 MB
            'backupCount': 5,
            'formatter': 'standard',
        },
        'log_filedb': {
            'level': 'DEBUG',
            'class': 'logging.handlers.RotatingFileHandler',
            'filename': '/tmp/eduduck_db.log',
            'maxBytes': 10*2**20, #10 MB
            'backupCount': 5,
            'formatter': 'standard',
        },
        'console': {
            'level': 'ERROR',
            'class': 'logging.StreamHandler',
            'formatter': 'standard',
        },
    },
    'loggers': {
        'django.request': {
            'handlers': ['mail_admins'],
            'level': 'ERROR',
            'propagate': True,
        },
        '': {
            'handlers': ['log_file', 'console'],
            'level': 'DEBUG',
            'propagate': True,
        },
        'django.db.backends': {
            'handlers': ['log_filedb', 'console'],
            'propagate': False,
            'level': 'DEBUG',
        },
    }
}

和 dev.py

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#settings/dev.py
from .base import *

DEBUG = True
TEMPLATE_DEBUG = DEBUG
TEMPLATE_STRING_IF_INVALID = 'INVALID_EXPRESSION: %s'

#django-registration needs an MTA. For development just use console
#smtp is the default, so in prod.py, EMAIL_BACKEND is commented out or missing
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'

#INSTALLED_APPS += ("debug_toolbar", )
#INTERNAL_IPS = ("127.0.0.1", )
#MIDDLEWARE_CLASSES += ("debug_toolbar.middleware.DebugToolbarMiddleware",)

DATABASES = {
    'default': {
        'ENGINE': 'mysql.connector.django',
        'NAME': 'ed_dev',
        'USER': 'ed_dev',                    
        'PASSWORD': 'quickquackquock',                
        'HOST': '',
        'PORT': '',
    },
# following is for resyncing database on staging server (would be better to
# get python manage.py to read the staging.py config, as opposed to having this here.
#    'mysql_sync': {
#        'ENGINE': 'django.db.backends.mysql',
#        'HOST': '',
#   'NAME': 'eduduck',
#   'USER': 'put it back if you need to resync',
#   'PORT': '2369',
#   'PASSWORD':"put it back if you need to resync",
#        'OPTIONS': {
#            'init_command': 'SET storage_engine=INNODB',
#        },
#    },
}

#Not very secret SECRET_KEY. Just for dev. Staging and prod. use env var.
SECRET_KEY = 'paranoid'

# Fixture Directory - for development purposes, reloading test data
# after changes to models.
FIXTURE_DIRS = (
    os.path.join(SITE_ROOT, 'fixtures/')
)

提前致谢,


django-registration 不支持 Python 3。
请改用 django-allauth。

你可以在这里找到很多关于 django-allauth 的信息:https://pypi.python.org/pypi/django-allauth

希望这会有所帮助。