来自https://pypi.python.org/pypi/django-ckeditor/5.0.1,与readthedocs同步:
。将CKEditor URL include添加到项目的
urls.py
文件::(r' ^ ckeditor /',include(' ckeditor_uploader.urls')),
我可以尝试添加上传者网址,但ckeditor_uploader
似乎没有成员urls
:
(pets-env) root@lists:~/pets# python manage.py shell
Python 2.7.9 (default, Jun 29 2016, 13:08:31)
[GCC 4.9.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> import ckeditor_uploader
>>> dir(ckeditor_uploader)
['ImproperlyConfigured', '__builtins__', '__doc__', '__file__', '__name__', '__package__', '__path__', 'absolute_import', 'settings']
>>> ckeditor_uploader.urls
Traceback (most recent call last):
File "<console>", line 1, in <module>
AttributeError: 'module' object has no attribute 'urls'
>>> dir(ckeditor_uploader.settings)
['ABSOLUTE_URL_OVERRIDES', 'ADMINS', 'ALLOWED_HOSTS', 'APPEND_SLASH', 'AUTHENTICATION_BACKENDS', 'AUTH_PASSWORD_VALIDATORS', 'AUTH_USER_MODEL', 'BASE_DIR', 'CACHES', 'CACHE_MIDDLEWARE_ALIAS', 'CACHE_MIDDLEWARE_KEY_PREFIX', 'CACHE_MIDDLEWARE_SECONDS', 'CKEDITOR_IMAGE_BACKEND', 'CKEDITOR_JQUERY_URL', 'CKEDITOR_UPLOAD_PATH', 'CSRF_COOKIE_AGE', 'CSRF_COOKIE_DOMAIN', 'CSRF_COOKIE_HTTPONLY', 'CSRF_COOKIE_NAME', 'CSRF_COOKIE_PATH', 'CSRF_COOKIE_SECURE', 'CSRF_FAILURE_VIEW', 'CSRF_HEADER_NAME', 'CSRF_TRUSTED_ORIGINS', 'DATABASES', 'DATABASE_ROUTERS', 'DATA_UPLOAD_MAX_MEMORY_SIZE', 'DATA_UPLOAD_MAX_NUMBER_FIELDS', 'DATETIME_FORMAT', 'DATETIME_INPUT_FORMATS', 'DATE_FORMAT', 'DATE_INPUT_FORMATS', 'DEBUG', 'DEBUG_PROPAGATE_EXCEPTIONS', 'DECIMAL_SEPARATOR', 'DEFAULT_CHARSET', 'DEFAULT_CONTENT_TYPE', 'DEFAULT_EXCEPTION_REPORTER_FILTER', 'DEFAULT_FILE_STORAGE', 'DEFAULT_FROM_EMAIL', 'DEFAULT_INDEX_TABLESPACE', 'DEFAULT_TABLESPACE', 'DISALLOWED_USER_AGENTS', 'EMAIL_BACKEND', 'EMAIL_HOST', 'EMAIL_HOST_PASSWORD', 'EMAIL_HOST_USER', 'EMAIL_PORT', 'EMAIL_SSL_CERTFILE', 'EMAIL_SSL_KEYFILE', 'EMAIL_SUBJECT_PREFIX', 'EMAIL_TIMEOUT', 'EMAIL_USE_SSL', 'EMAIL_USE_TLS', 'FILE_CHARSET', 'FILE_UPLOAD_DIRECTORY_PERMISSIONS', 'FILE_UPLOAD_HANDLERS', 'FILE_UPLOAD_MAX_MEMORY_SIZE', 'FILE_UPLOAD_PERMISSIONS', 'FILE_UPLOAD_TEMP_DIR', 'FIRST_DAY_OF_WEEK', 'FIXTURE_DIRS', 'FORCE_SCRIPT_NAME', 'FORMAT_MODULE_PATH', 'IGNORABLE_404_URLS', 'INSTALLED_APPS', 'INTERNAL_IPS', 'LANGUAGES', 'LANGUAGES_BIDI', 'LANGUAGE_CODE', 'LANGUAGE_COOKIE_AGE', 'LANGUAGE_COOKIE_DOMAIN', 'LANGUAGE_COOKIE_NAME', 'LANGUAGE_COOKIE_PATH', 'LOCALE_PATHS', 'LOGGING', 'LOGGING_CONFIG', 'LOGIN_REDIRECT_URL', 'LOGIN_URL', 'LOGOUT_REDIRECT_URL', 'MANAGERS', 'MEDIA_ROOT', 'MEDIA_URL', 'MESSAGE_STORAGE', 'MIDDLEWARE', 'MIDDLEWARE_CLASSES', 'MIGRATION_MODULES', 'MONTH_DAY_FORMAT', 'NUMBER_GROUPING', 'PASSWORD_HASHERS', 'PASSWORD_RESET_TIMEOUT_DAYS', 'PREPEND_WWW', 'ROOT_URLCONF', 'SECRET_KEY', 'SECURE_BROWSER_XSS_FILTER', 'SECURE_CONTENT_TYPE_NOSNIFF', 'SECURE_HSTS_INCLUDE_SUBDOMAINS', 'SECURE_HSTS_SECONDS', 'SECURE_PROXY_SSL_HEADER', 'SECURE_REDIRECT_EXEMPT', 'SECURE_SSL_HOST', 'SECURE_SSL_REDIRECT', 'SERVER_EMAIL', 'SESSION_CACHE_ALIAS', 'SESSION_COOKIE_AGE', 'SESSION_COOKIE_DOMAIN', 'SESSION_COOKIE_HTTPONLY', 'SESSION_COOKIE_NAME', 'SESSION_COOKIE_PATH', 'SESSION_COOKIE_SECURE', 'SESSION_ENGINE', 'SESSION_EXPIRE_AT_BROWSER_CLOSE', 'SESSION_FILE_PATH', 'SESSION_SAVE_EVERY_REQUEST', 'SESSION_SERIALIZER', 'SETTINGS_MODULE', 'SHORT_DATETIME_FORMAT', 'SHORT_DATE_FORMAT', 'SIGNING_BACKEND', 'SILENCED_SYSTEM_CHECKS', 'SITE_NAME', 'STATICFILES_DIRS', 'STATICFILES_FINDERS', 'STATICFILES_STORAGE', 'STATIC_ROOT', 'STATIC_URL', 'TEMPLATES', 'TEST_NON_SERIALIZED_APPS', 'TEST_RUNNER', 'THOUSAND_SEPARATOR', 'TIME_FORMAT', 'TIME_INPUT_FORMATS', 'TIME_ZONE', 'USE_ETAGS', 'USE_I18N', 'USE_L10N', 'USE_THOUSAND_SEPARATOR', 'USE_TZ', 'USE_X_FORWARDED_HOST', 'USE_X_FORWARDED_PORT', 'WSGI_APPLICATION', 'X_FRAME_OPTIONS', 'YEAR_MONTH_FORMAT', '__class__', '__delattr__', '__dict__', '__doc__', '__format__', '__getattribute__', '__hash__', '__init__', '__module__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_explicit_settings', 'is_overridden']
我应该如何插入ckeditor及其上传器?
谢谢,
答案 0 :(得分:0)
你从实际的python callables(类,函数)或变量中混淆了python模块。
你看,ckeditor_uploader
是一个包(一个模块)。该模块还有其他一些模块等。
执行此操作ckeditor_uploader.url
时,您说:嘿,请从url
实例(或类或其他)中获取ckeditor_uploader
属性。但是,你看,ckeditor_uploader
既不是一个类,也不是一个方法,也不是一个能够拥有属性的东西。它只是一个模块(一个python可识别的目录,如果你愿意),它包含其他文件,而在这些文件中有类,函数等。
所以,现在问题。而不是ckeditor_uploader.urls
执行此操作:
from ckeditor_uploader import urls
print(type(urls)) # <class 'module'>
请注意,您刚刚导入了urls
模块。现在你可以做这样的事情:
urls.urlpatterns
因为urls
python文件在其中声明了urlpatterns
变量。