博客升级,Django1.6 to Django1.7的坑
第一个坑,django-ckeditor引发,
File "manage.py", line 10, in
execute_from_command_line(sys.argv)
File "/Library/Python/2.7/site-packages/Django-1.7-py2.7.egg/django/core/management/__init__.py", line 385, in execute_from_command_line
utility.execute()
File "/Library/Python/2.7/site-packages/Django-1.7-py2.7.egg/django/core/management/__init__.py", line 354, in execute
django.setup()
File "/Library/Python/2.7/site-packages/Django-1.7-py2.7.egg/django/__init__.py", line 21, in setup
apps.populate(settings.INSTALLED_APPS)
File "/Library/Python/2.7/site-packages/Django-1.7-py2.7.egg/django/apps/registry.py", line 115, in populate
app_config.ready()
File "/Library/Python/2.7/site-packages/Django-1.7-py2.7.egg/django/contrib/admin/apps.py", line 22, in ready
self.module.autodiscover()
File "/Library/Python/2.7/site-packages/Django-1.7-py2.7.egg/django/contrib/admin/__init__.py", line 23, in autodiscover
autodiscover_modules('admin', register_to=site)
File "/Library/Python/2.7/site-packages/Django-1.7-py2.7.egg/django/utils/module_loading.py", line 74, in autodiscover_modules
import_module('%s.%s' % (app_config.name, module_to_search))
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/Users/Alan/Workspace/laonan.net/member/admin.py", line 37, in
class UserChangeForm(forms.ModelForm):
File "/Library/Python/2.7/site-packages/Django-1.7-py2.7.egg/django/forms/models.py", line 284, in __new__
opts.help_texts, opts.error_messages)
File "/Library/Python/2.7/site-packages/Django-1.7-py2.7.egg/django/forms/models.py", line 210, in fields_for_model
formfield = f.formfield(**kwargs)
File "/Library/Python/2.7/site-packages/django_ckeditor-4.2.8-py2.7.egg/ckeditor/fields.py", line 18, in formfield
return super(RichTextField, self).formfield(**defaults)
File "/Library/Python/2.7/site-packages/Django-1.7-py2.7.egg/django/db/models/fields/__init__.py", line 1892, in formfield
return super(TextField, self).formfield(**defaults)
File "/Library/Python/2.7/site-packages/Django-1.7-py2.7.egg/django/db/models/fields/__init__.py", line 842, in formfield
return form_class(**defaults)
File "/Library/Python/2.7/site-packages/django_ckeditor-4.2.8-py2.7.egg/ckeditor/fields.py", line 24, in __init__
super(RichTextFormField, self).__init__(*args, **kwargs)
TypeError: Error when calling the metaclass bases
__init__() got an unexpected keyword argument 'max_length'
填坑:把django-ckeditor升级到4.4+,并且重新执行python manager collectstatics更新静态资源,还有,需要在settings.py单独为ckeditor加上jquery引用。
CKEDITOR_JQUERY_URL = '//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js'
第二个小坑,执行python manager.py runserver,结果如下:
Performing system checks...
System check identified some issues:
WARNINGS:
?: (1_6.W001) Some project unittests may not execute as expected.
HINT: Django 1.6 introduced a new default test runner. It looks like this project was generated using Django 1.5 or earlier. You should ensure your tests are all running & behaving as expected. See https://docs.djangoproject.com/en/dev/releases/1.6/#new-test-runner for more information.
System check identified 1 issue (0 silenced).
You have unapplied migrations; your app may not work properly until they are applied.
Run 'python manage.py migrate' to apply them.
第二个issue很好办,执行一下python manage.py migrate就完了,至于前面blabla关于unittests的部分,偶卖糕的,还要写单元测试啊。
最后,如果懒的话,在settings.py里加上这么一句吧,这下世界清静了。
TEST_RUNNER = 'django.test.runner.DiscoverRunner'
最后,博客URL改为UUID,其实我是很喜欢数字作为url的一部分的,多简洁,可是,为了防垃圾爬虫,改先,万一以后我这博客是知名博客了,再来改就来不及了。