我正在尝试使用 django-registration 1.0 将名为 course 的 web 应用程序从 Django 1.4 升级到 1.6。其他 django-registration 线程似乎都没有与此问题相关的任何内容。
我正在通过 python manage.py 测试课程运行单元测试,该课程崩溃并出现以下跟踪:
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 | -> 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:
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 | 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
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 | 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
希望这会有所帮助。
关闭。这个问题是opinion-based.它目前不接受答案。想要改进这个问题?更新问题,以便editingthispost可以用事实和引用来回答它.关闭4年前。Improvethisquestion我想在固定时间创建一系列低音和高音调的哔哔声。例如:在150毫秒时发出高音调的蜂鸣声在151毫秒时发出低音调的蜂鸣声200毫秒时发出低音调的蜂鸣声250毫秒的高音调蜂鸣声有没有办法在Ruby或Python中做到这一点?我真的不在乎输出编码是什么(.wav、.mp3、.ogg等等),但我确实想创建一个输出文件。
这个问题在这里已经有了答案:关闭10年前。PossibleDuplicate:Pythonconditionalassignmentoperator对于这样一个简单的问题表示歉意,但是谷歌搜索||=并不是很有帮助;)Python中是否有与Ruby和Perl中的||=语句等效的语句?例如:foo="hey"foo||="what"#assignfooifit'sundefined#fooisstill"hey"bar||="yeah"#baris"yeah"另外,类似这样的东西的通用术语是什么?条件分配是我的第一个猜测,但Wikipediapage跟我想的不太一样。
什么是ruby的rack或python的Java的wsgi?还有一个路由库。 最佳答案 来自Python标准PEP333:Bycontrast,althoughJavahasjustasmanywebapplicationframeworksavailable,Java's"servlet"APImakesitpossibleforapplicationswrittenwithanyJavawebapplicationframeworktoruninanywebserverthatsupportstheservletAPI.ht
华为OD机试题本篇题目:明明的随机数题目输入描述输出描述:示例1输入输出说明代码编写思路最近更新的博客华为od2023|什么是华为od,od薪资待遇,od机试题清单华为OD机试真题大全,用Python解华为机试题|机试宝典【华为OD机试】全流程解析+经验分享,题型分享,防作弊指南华为o
我想解析一个已经存在的.mid文件,改变它的乐器,例如从“acousticgrandpiano”到“violin”,然后将它保存回去或作为另一个.mid文件。根据我在文档中看到的内容,该乐器通过program_change或patch_change指令进行了更改,但我找不到任何在已经存在的MIDI文件中执行此操作的库.他们似乎都只支持从头开始创建的MIDI文件。 最佳答案 MIDIpackage会为您完成此操作,但具体方法取决于midi文件的原始内容。一个MIDI文件由一个或多个音轨组成,每个音轨是十六个channel中任何一个上的
本文主要介绍在使用Selenium进行自动化测试或者任务时,对于使用了iframe的页面,如何定位iframe中的元素文章目录场景描述解决方案具体代码场景描述当我们在使用Selenium进行自动化测试的时候,可能会遇到一些界面或者窗体是使用HTML的iframe标签进行承载的。对于iframe中的标签,如果直接查找是无法找到的,会抛出没有找到元素的异常。比如近在咫尺的例子就是,CSDN的登录窗体就是使用的iframe,大家可以尝试通过F12开发者模式查看到的tag_name,class_name,id或者xpath来定位中的页面元素,会抛出NoSuchElementException异常。解决
2022/8/4更新支持加入水印水印必须包含透明图像,并且水印图像大小要等于原图像的大小pythonconvert_image_to_video.py-f30-mwatermark.pngim_dirout.mkv2022/6/21更新让命令行参数更加易用新的命令行使用方法pythonconvert_image_to_video.py-f30im_dirout.mkvFFMPEG命令行转换一组JPG图像到视频时,是将这组图像视为MJPG流。我需要转换一组PNG图像到视频,FFMPEG就不认了。pyav内置了ffmpeg库,不需要系统带有ffmpeg工具因此我使用ffmpeg的python包装p
ValidPalindromeGivenastring,determineifitisapalindrome,consideringonlyalphanumericcharactersandignoringcases. [#125]Example:"Aman,aplan,acanal:Panama"isapalindrome."raceacar"isnotapalindrome.Haveyouconsiderthatthestringmightbeempty?Thisisagoodquestiontoaskduringaninterview.Forthepurposeofthisproblem
是否可以在PyYAML或Ruby的Psych引擎中禁用创建anchor和引用(并有效地显式列出冗余数据)?也许我在网上搜索时遗漏了一些东西,但在Psych中似乎没有太多可用的选项,而且我也无法确定PyYAML是否允许这样做.基本原理是我必须序列化一些数据并将其以可读的形式传递给一个不是真正的技术同事进行手动验证。有些数据是多余的,但我需要以最明确的方式列出它们以提高可读性(anchor和引用是提高效率的好概念,但不是人类可读性)。Ruby和Python是我选择的工具,但如果有其他一些相当简单的方法来“展开”YAML文档,它可能就可以了。 最佳答案
我很好奇.NET将如何影响Python和Ruby应用程序。用IronPython/IronRuby编写的应用程序是否会非常特定于.NET环境,以至于它们实际上将变得特定于平台?如果他们不使用任何.NET功能,那么IronPython/IronRuby相对于非.NET同类产品的优势是什么? 最佳答案 我不能说任何关于IronRuby的东西,但是大多数Python实现(如IronPython、Jython和PyPy)都试图尽可能忠实于CPython实现。不过,IronPython正在迅速成为这方面的佼佼者之一,并且在PlanetPyth