Server deployment Django startup error, UEditor problem handling

The following question is that appears when installing Django UEditor under Ubuntu18

ModuleNotFoundError: No module named 'widgets'

How to deal with this problem:

Download the latest version of DjangoUed3, download DjangoUeditor compatible with python3 on github, and put DjangoUeditor into your own virtual environment.

Then it will report the following error:

ImportError: No module named 'settings'

This is because, in the widgets.py import under DjangoUeditor in the python environment, 

import settings as USettings

 The import here needs to be modified to

from . import settings as USettings

This problem can be solved

Then there is the next question

AttributeError: 'dict' object has no attribute 'has_key'

File "/root/.virtualenvs/abc_block_chain/lib/python3.6/site-packages/DjangoUeditor/models.py", line 4, in <module>
    from .widgets import UEditorWidget, AdminUEditorWidget
  File "/root/.virtualenvs/abc_block_chain/lib/python3.6/site-packages/DjangoUeditor/widgets.py", line 8, in <module>
    from . import settings as USettings
  File "/root/.virtualenvs/abc_block_chain/lib/python3.6/site-packages/DjangoUeditor/settings.py", line 101, in <module>
    UpdateUserSettings()
  File "/root/.virtualenvs/abc_block_chain/lib/python3.6/site-packages/DjangoUeditor/settings.py", line 97, in UpdateUserSettings
    if UserSettings.has_key("config"):UEditorSettings.update(UserSettings["config"])
AttributeError: 'dict' object has no attribute 'has_key'

 For this problem, we need to modify the corresponding content in settings.py. Modify as follows:

#更新配置:从用户配置文件settings.py重新读入配置UEDITOR_SETTINGS,覆盖默认
def UpdateUserSettings():
    UserSettings=getattr(gSettings,"UEDITOR_SETTINGS",{}).copy()
    #if UserSettings.has_key("config"):UEditorSettings.update(UserSettings["config"])
    if UserSettings.get("config"):UEditorSettings.update(UserSettings["config"])
    #if UserSettings.has_key("upload"):UEditorUploadSettings.update(UserSettings["upload"])
    if UserSettings.get("upload"):UEditorUploadSettings.update(UserSettings["upload"])

#读取用户Settings文件并覆盖默认配置
UpdateUserSettings()


#取得配置项参数
def GetUeditorSettings(key,default=None):
    #if UEditorSettings.has_key(key):
    if UEditorSettings.get(key):
        return UEditorSettings[key]
    else:
        return default

 

 

After the modification, the error will continue to be reported:

ModuleNotFoundError: No module named 'settings'

    from .widgets import UEditorWidget, AdminUEditorWidget
  File "/root/.virtualenvs/abc_block_chain/lib/python3.6/site-packages/DjangoUeditor/widgets.py", line 9, in <module>
    from .commands import *
  File "/root/.virtualenvs/abc_block_chain/lib/python3.6/site-packages/DjangoUeditor/commands.py", line 3, in <module>
    import settings as USettings
ModuleNotFoundError: No module named 'settings'

See that it is a problem of importing settings in commands.py. The solution is the same as above.

After starting, it is normal. At this point, the handling of UEditor issues related to Django server installation is basically the same.

 

 

Guess you like

Origin blog.csdn.net/u012798683/article/details/107320708