5-2 xadmin的安装

xadmin是基于django admin的一套后台管理系统,比django自带的admin更强大的管理系统。

xadmin有两种安装方式:

第一种:

5-2 xadmin的安装_第1张图片

自动安装另外三个依赖包

5-2 xadmin的安装_第2张图片

安装完成之后,直接在setting.py里配置

5-2 xadmin的安装_第3张图片

 

C:\Users\hlg\PycharmProjects\MxOnline\MxOnline\urls.py

5-2 xadmin的安装_第4张图片

然后把默认的admin注销掉

5-2 xadmin的安装_第5张图片

删除

重启系统。

访问:http://127.0.0.1:8000/xadmin/

报错:

ProgrammingError at /xadmin/
(1146, "Table 'mxonline.xadmin_usersettings' doesn't exist")
Request Method:	GET
Request URL:	http://127.0.0.1:8000/xadmin/
Django Version:	1.9
Exception Type:	ProgrammingError
Exception Value:	
(1146, "Table 'mxonline.xadmin_usersettings' doesn't exist")
Exception Location:	C:\Users\hlg\Envs\mxonline\lib\site-packages\MySQLdb\connections.py in defaulterrorhandler, line 36
Python Executable:	C:\Users\hlg\Envs\mxonline\Scripts\python.exe
Python Version:	2.7.12
Python Path:	
['C:\\Users\\hlg\\PycharmProjects\\MxOnline\\apps',
 'C:\\Users\\hlg\\PycharmProjects\\MxOnline',
 'C:\\Users\\hlg\\PycharmProjects\\MxOnline',
 'C:\\Users\\hlg\\PycharmProjects\\MxOnline\\apps',
 'C:\\Windows\\system32\\python27.zip',
 'C:\\Users\\hlg\\Envs\\mxonline\\DLLs',
 'C:\\Users\\hlg\\Envs\\mxonline\\lib',
 'C:\\Users\\hlg\\Envs\\mxonline\\lib\\plat-win',
 'C:\\Users\\hlg\\Envs\\mxonline\\lib\\lib-tk',
 'C:\\Users\\hlg\\Envs\\mxonline\\Scripts',
 'c:\\python27\\Lib',
 'c:\\python27\\DLLs',
 'c:\\python27\\Lib\\lib-tk',
 'C:\\Users\\hlg\\Envs\\mxonline',
 'C:\\Users\\hlg\\Envs\\mxonline\\lib\\site-packages']
Server time:	星期二, 5 六月 2018 19:32:12 +0800

是因为xadmin有一些默认的表,需要把xadmin同步过来。

5-2 xadmin的安装_第6张图片

查看一下数据库的表:

5-2 xadmin的安装_第7张图片

 

刷新页面,重新登录

5-2 xadmin的安装_第8张图片

 

成功。

百度搜索xadmin,可以了解xadmin的信息

5-2 xadmin的安装_第9张图片

 

第二种:

基于源码安装

浏览器访问:github.com

搜索:xadmin,然后回车

5-2 xadmin的安装_第10张图片

 

搜索结果:

5-2 xadmin的安装_第11张图片

第一条搜索结果

点击进去,xadmin的源码地址

5-2 xadmin的安装_第12张图片

下载源码,解压,把xadmin文件拷贝到,项目的根目录下

5-2 xadmin的安装_第13张图片

5-2 xadmin的安装_第14张图片

然后新建一个new package,extra_apps

5-2 xadmin的安装_第15张图片

然后把xadmin拖进extra_apps

5-2 xadmin的安装_第16张图片

 

把extra_apps,Mark一下

5-2 xadmin的安装_第17张图片

卸载之前安装的xadmin

5-2 xadmin的安装_第18张图片

pip list查看一下

5-2 xadmin的安装_第19张图片

但是,依赖包没有卸载掉,因为我们还是需要的

重启启动:

报错

"C:\Program Files\JetBrains\PyCharm 2017.1.3\bin\runnerw.exe" C:\Users\hlg\Envs\mxonline\Scripts\python.exe C:/Users/hlg/PycharmProjects/MxOnline/manage.py runserver 8000
Traceback (most recent call last):
  File "C:/Users/hlg/PycharmProjects/MxOnline/manage.py", line 10, in 
    execute_from_command_line(sys.argv)
  File "C:\Users\hlg\Envs\mxonline\lib\site-packages\django\core\management\__init__.py", line 350, in execute_from_command_line
    utility.execute()
  File "C:\Users\hlg\Envs\mxonline\lib\site-packages\django\core\management\__init__.py", line 342, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "C:\Users\hlg\Envs\mxonline\lib\site-packages\django\core\management\__init__.py", line 176, in fetch_command
    commands = get_commands()
  File "C:\Users\hlg\Envs\mxonline\lib\site-packages\django\utils\lru_cache.py", line 100, in wrapper
    result = user_function(*args, **kwds)
  File "C:\Users\hlg\Envs\mxonline\lib\site-packages\django\core\management\__init__.py", line 71, in get_commands
    for app_config in reversed(list(apps.get_app_configs())):
  File "C:\Users\hlg\Envs\mxonline\lib\site-packages\django\apps\registry.py", line 137, in get_app_configs
    self.check_apps_ready()
  File "C:\Users\hlg\Envs\mxonline\lib\site-packages\django\apps\registry.py", line 124, in check_apps_ready
    raise AppRegistryNotReady("Apps aren't loaded yet.")
django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet.

Process finished with exit code 1

 

试着修改:

 

5-2 xadmin的安装_第20张图片

再安装

5-2 xadmin的安装_第21张图片

 

还是报错:

"C:\Program Files\JetBrains\PyCharm 2017.1.3\bin\runnerw.exe" C:\Users\hlg\Envs\mxonline\Scripts\python.exe C:/Users/hlg/PycharmProjects/MxOnline/manage.py runserver 8000
Unhandled exception in thread started by 
Traceback (most recent call last):
  File "C:\Users\hlg\Envs\mxonline\lib\site-packages\django\utils\autoreload.py", line 226, in wrapper
    fn(*args, **kwargs)
  File "C:\Users\hlg\Envs\mxonline\lib\site-packages\django\core\management\commands\runserver.py", line 109, in inner_run
    autoreload.raise_last_exception()
  File "C:\Users\hlg\Envs\mxonline\lib\site-packages\django\utils\autoreload.py", line 249, in raise_last_exception
    six.reraise(*_exception)
  File "C:\Users\hlg\Envs\mxonline\lib\site-packages\django\utils\autoreload.py", line 226, in wrapper
    fn(*args, **kwargs)
  File "C:\Users\hlg\Envs\mxonline\lib\site-packages\django\__init__.py", line 18, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "C:\Users\hlg\Envs\mxonline\lib\site-packages\django\apps\registry.py", line 115, in populate
    app_config.ready()
  File "C:\Users\hlg\PycharmProjects\MxOnline\extra_apps\xadmin\apps.py", line 14, in ready
    self.module.autodiscover()
  File "C:\Users\hlg\PycharmProjects\MxOnline\extra_apps\xadmin\__init__.py", line 49, in autodiscover
    register_builtin_plugins(site)
  File "C:\Users\hlg\PycharmProjects\MxOnline\extra_apps\xadmin\plugins\__init__.py", line 41, in register_builtin_plugins
    [import_module('xadmin.plugins.%s' % plugin) for plugin in PLUGINS if plugin not in exclude_plugins]
  File "c:\python27\Lib\importlib\__init__.py", line 37, in import_module
    __import__(name)
  File "C:\Users\hlg\PycharmProjects\MxOnline\extra_apps\xadmin\plugins\importexport.py", line 48, in 
    from import_export.admin import DEFAULT_FORMATS, SKIP_ADMIN_LOG, TMP_STORAGE_CLASS
ImportError: No module named import_export.admin

 

最后一步:

 

终于搞定.

 

C:\Users\huang\PycharmProjects\GroupPurchase\extra_apps\xadmin\views\dashboard.py changed, reloading.
pydev debugger: process 63956 is connecting

Watching for file changes with StatReloader
Exception in thread django-main-thread:
Traceback (most recent call last):
  File "C:\Users\huang\AppData\Local\Programs\Python\Python36\Lib\threading.py", line 916, in _bootstrap_inner
    self.run()
  File "C:\Users\huang\AppData\Local\Programs\Python\Python36\Lib\threading.py", line 864, in run
    self._target(*self._args, **self._kwargs)
  File "D:\Envs\GroupPurchase\lib\site-packages\django\utils\autoreload.py", line 54, in wrapper
    fn(*args, **kwargs)
  File "D:\Envs\GroupPurchase\lib\site-packages\django\core\management\commands\runserver.py", line 109, in inner_run
    autoreload.raise_last_exception()
  File "D:\Envs\GroupPurchase\lib\site-packages\django\utils\autoreload.py", line 77, in raise_last_exception
    raise _exception[1]
  File "D:\Envs\GroupPurchase\lib\site-packages\django\core\management\__init__.py", line 337, in execute
    autoreload.check_errors(django.setup)()
  File "D:\Envs\GroupPurchase\lib\site-packages\django\utils\autoreload.py", line 54, in wrapper
    fn(*args, **kwargs)
  File "D:\Envs\GroupPurchase\lib\site-packages\django\__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "D:\Envs\GroupPurchase\lib\site-packages\django\apps\registry.py", line 122, in populate
    app_config.ready()
  File "C:\Users\huang\PycharmProjects\GroupPurchase\extra_apps\xadmin\apps.py", line 14, in ready
    self.module.autodiscover()
  File "C:\Users\huang\PycharmProjects\GroupPurchase\extra_apps\xadmin\__init__.py", line 29, in autodiscover
    from xadmin.views import register_builtin_views
  File "C:\Users\huang\PycharmProjects\GroupPurchase\extra_apps\xadmin\views\__init__.py", line 10, in 
    from .dashboard import Dashboard, BaseWidget, widget_manager, ModelDashboard
  File "C:\Users\huang\PycharmProjects\GroupPurchase\extra_apps\xadmin\views\dashboard.py", line 316, in 
    class ModelBaseWidget(BaseWidget):
  File "C:\Users\huang\PycharmProjects\GroupPurchase\extra_apps\xadmin\views\dashboard.py", line 321, in ModelBaseWidget
    model = ModelChoiceField(label=_(u'Target Model'), widget=exwidgets.AdminSelectWidget)
  File "C:\Users\huang\PycharmProjects\GroupPurchase\extra_apps\xadmin\views\dashboard.py", line 285, in __init__
    *args, **kwargs)
TypeError: __init__() takes 1 positional argument but 6 were given
  • 解决方案:
把forms.Field.__init__(self, required, widget, label, initial, help_text, *args, **kwargs) 修改成forms.Field.__init__(self)

报错:

from django.db.models.sql.constants import QUERY_TERMS

解决方案:

from django.db.models.sql.query import LOOKUP_SEP

from django.db.models.sql.constants import QUERY_TERMS

 

报错:

ModuleNotFoundError: No module named 'django.core.urlresolvers'

解决方法:

from django.core.urlresolvers import reverse

改成:

from django.urls import reverse

 

报错:

ModuleNotFoundError: No module named 'django.contrib.formtools'

解决方法:

pip install django-formtools==2.1
 

报错:

ModuleNotFoundError: No module named 'import_export'

需要安装 

pip install django-import_export

   在虚拟环境下

 

 

====

pip  install  -i  https://pypi.doubanio.com/simple/  --trusted-host pypi.doubanio.com  django-crispy-forms==1.7.2
pip  install  -i  https://pypi.doubanio.com/simple/  --trusted-host pypi.doubanio.com  django-formtools==2.1
pip  install  -i  https://pypi.doubanio.com/simple/  --trusted-host pypi.doubanio.com  httplib2==0.9.2

运行项目

5-2 xadmin的安装_第22张图片

点击 日志记录

报错:

Failed to get real commands on module "MxOnline": python process died with code 1: Traceback (most recent call last):
  File "C:\Program Files\JetBrains\PyCharm 2017.1.3\helpers\pycharm\_jb_manage_tasks_provider.py", line 25, in 
    django.setup()
  File "C:\Users\hlg\Envs\mxonline\lib\site-packages\django\__init__.py", line 18, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "C:\Users\hlg\Envs\mxonline\lib\site-packages\django\apps\registry.py", line 85, in populate
    app_config = AppConfig.create(entry)
  File "C:\Users\hlg\Envs\mxonline\lib\site-packages\django\apps\config.py", line 123, in create
    import_module(entry)
  File "c:\python27\Lib\importlib\__init__.py", line 37, in import_module
    __import__(name)
  File "C:\Users\hlg\PycharmProjects\MxOnline\extra_apps\xadmin\__init__.py", line 4, in 
    from xadmin.sites import AdminSite, site
ImportError: No module named xadmin.sites

manage.py@MxOnline > makemigrations
"C:\Program Files\JetBrains\PyCharm 2017.1.3\bin\runnerw.exe" C:\Users\hlg\Envs\mxonline\Scripts\python.exe "C:\Program Files\JetBrains\PyCharm 2017.1.3\helpers\pycharm\django_manage.py" makemigrations C:/Users/hlg/PycharmProjects/MxOnline
Traceback (most recent call last):
  File "C:\Program Files\JetBrains\PyCharm 2017.1.3\helpers\pycharm\django_manage.py", line 43, in 
    run_module(manage_file, None, '__main__', True)
  File "c:\python27\Lib\runpy.py", line 188, in run_module
    fname, loader, pkg_name)
  File "c:\python27\Lib\runpy.py", line 82, in _run_module_code
    mod_name, mod_fname, mod_loader, pkg_name)
  File "c:\python27\Lib\runpy.py", line 72, in _run_code
    exec code in run_globals
  File "C:\Users\hlg\PycharmProjects\MxOnline\manage.py", line 10, in 
    execute_from_command_line(sys.argv)
  File "C:\Users\hlg\Envs\mxonline\lib\site-packages\django\core\management\__init__.py", line 350, in execute_from_command_line
    utility.execute()
  File "C:\Users\hlg\Envs\mxonline\lib\site-packages\django\core\management\__init__.py", line 324, in execute
    django.setup()
  File "C:\Users\hlg\Envs\mxonline\lib\site-packages\django\__init__.py", line 18, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "C:\Users\hlg\Envs\mxonline\lib\site-packages\django\apps\registry.py", line 85, in populate
    app_config = AppConfig.create(entry)
  File "C:\Users\hlg\Envs\mxonline\lib\site-packages\django\apps\config.py", line 123, in create
    import_module(entry)
  File "c:\python27\Lib\importlib\__init__.py", line 37, in import_module
    __import__(name)
  File "C:/Users/hlg/PycharmProjects/MxOnline\extra_apps\xadmin\__init__.py", line 4, in 
    from xadmin.sites import AdminSite, site
ImportError: No module named xadmin.sites

Process finished with exit code 1

 

 

 

xadmin 无法创建xadmin_log 或者是xadmin源代码使用,没有引用xadmin包报错或 1146, "Table 'mxonline.xadmin_log' doesn't exist"

解决方案:

第一步:将xadmin所在的目录为source_root

第二步:在settings.py中引用xadmin所在的目录

第三步makemigrations和migrate

5-2 xadmin的安装_第23张图片

 

 

 

 

"C:\Program Files\JetBrains\PyCharm 2017.2.7\bin\runnerw.exe" D:\Envs\zhanglijie\Scripts\python.exe "C:\Program Files\JetBrains\PyCharm 2017.2.7\helpers\pydev\pydevd.py" --multiproc --qt-support=auto --client 127.0.0.1 --port 51946 --file C:/Users/huang/PycharmProjects/fenghua/manage.py runserver 0.0.0.0:8000
pydev debugger: process 2112 is connecting

Connected to pydev debugger (build 172.4574.37)
pydev debugger: process 23440 is connecting

Unhandled exception in thread started by <_pydev_bundle.pydev_monkey._NewThreadStartupWithTrace object at 0x0000026E3A2B2BE0>
Traceback (most recent call last):
  File "C:\Program Files\JetBrains\PyCharm 2017.2.7\helpers\pydev\_pydev_bundle\pydev_monkey.py", line 589, in __call__
    return self.original_func(*self.args, **self.kwargs)
  File "D:\Envs\zhanglijie\lib\site-packages\django\utils\autoreload.py", line 225, in wrapper
    fn(*args, **kwargs)
  File "D:\Envs\zhanglijie\lib\site-packages\django\core\management\commands\runserver.py", line 112, in inner_run
    autoreload.raise_last_exception()
  File "D:\Envs\zhanglijie\lib\site-packages\django\utils\autoreload.py", line 248, in raise_last_exception
    raise _exception[1]
  File "D:\Envs\zhanglijie\lib\site-packages\django\core\management\__init__.py", line 327, in execute
    autoreload.check_errors(django.setup)()
  File "D:\Envs\zhanglijie\lib\site-packages\django\utils\autoreload.py", line 225, in wrapper
    fn(*args, **kwargs)
  File "D:\Envs\zhanglijie\lib\site-packages\django\__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "D:\Envs\zhanglijie\lib\site-packages\django\apps\registry.py", line 89, in populate
    app_config = AppConfig.create(entry)
  File "D:\Envs\zhanglijie\lib\site-packages\django\apps\config.py", line 90, in create
    module = import_module(entry)
  File "D:\Envs\zhanglijie\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "", line 978, in _gcd_import
  File "", line 961, in _find_and_load
  File "", line 950, in _find_and_load_unlocked
  File "", line 655, in _load_unlocked
  File "", line 678, in exec_module
  File "", line 205, in _call_with_frames_removed
  File "C:\Users\huang\PycharmProjects\fenghua\extra_apps\xadmin\__init__.py", line 4, in 
    from extra_apps.xadmin import site
  File "C:/Users/huang/PycharmProjects/fenghua\extra_apps\xadmin\__init__.py", line 4, in 
    from extra_apps.xadmin import site
ImportError: cannot import name 'site'

 

"C:\Program Files\JetBrains\PyCharm 2017.2.7\bin\runnerw.exe" D:\Envs\GroupPurchase\Scripts\python.exe "C:\Program Files\JetBrains\PyCharm 2017.2.7\helpers\pydev\pydevd.py" --multiproc --qt-support=auto --client 127.0.0.1 --port 49698 --file C:/Users/huang/PycharmProjects/gp/manage.py runserver 8000
pydev debugger: process 24704 is connecting

Connected to pydev debugger (build 172.4574.37)
pydev debugger: process 29648 is connecting

Unhandled exception in thread started by <_pydev_bundle.pydev_monkey._NewThreadStartupWithTrace object at 0x0000022D8BB2EF98>
Traceback (most recent call last):
  File "C:\Program Files\JetBrains\PyCharm 2017.2.7\helpers\pydev\_pydev_bundle\pydev_monkey.py", line 589, in __call__
    return self.original_func(*self.args, **self.kwargs)
  File "D:\Envs\GroupPurchase\lib\site-packages\django\utils\autoreload.py", line 225, in wrapper
    fn(*args, **kwargs)
  File "D:\Envs\GroupPurchase\lib\site-packages\django\core\management\commands\runserver.py", line 112, in inner_run
    autoreload.raise_last_exception()
  File "D:\Envs\GroupPurchase\lib\site-packages\django\utils\autoreload.py", line 248, in raise_last_exception
    raise _exception[1]
  File "D:\Envs\GroupPurchase\lib\site-packages\django\core\management\__init__.py", line 327, in execute
    autoreload.check_errors(django.setup)()
  File "D:\Envs\GroupPurchase\lib\site-packages\django\utils\autoreload.py", line 225, in wrapper
    fn(*args, **kwargs)
  File "D:\Envs\GroupPurchase\lib\site-packages\django\__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "D:\Envs\GroupPurchase\lib\site-packages\django\apps\registry.py", line 89, in populate
    app_config = AppConfig.create(entry)
  File "D:\Envs\GroupPurchase\lib\site-packages\django\apps\config.py", line 90, in create
    module = import_module(entry)
  File "D:\Envs\GroupPurchase\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "", line 978, in _gcd_import
  File "", line 961, in _find_and_load
  File "", line 950, in _find_and_load_unlocked
  File "", line 655, in _load_unlocked
  File "", line 678, in exec_module
  File "", line 205, in _call_with_frames_removed
  File "C:\Users\huang\PycharmProjects\gp\extra_apps\xadmin\__init__.py", line 4, in 
    from extra_apps.xadmin import site
  File "C:\Users\huang\PycharmProjects\gp\extra_apps\xadmin\__init__.py", line 4, in 
    from extra_apps.xadmin import site
ImportError: cannot import name 'site'

 

解决办法:

C:\Users\huang\PycharmProjects\gp\extra_apps\xadmin\__init__.py

# from extra_apps.xadmin import site
from xadmin.sites import AdminSite, site
    from extra_apps.xadmin.views import register_builtin_views
    register_builtin_views(site)

 

 

又报错:

RuntimeError: Model class xadmin.models.Bookmark doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS.

 

报错:

"C:\Program Files\JetBrains\PyCharm 2017.2.7\bin\runnerw.exe" C:\Users\huang\AppData\Local\Programs\Python\Python36\python.exe "C:\Program Files\JetBrains\PyCharm 2017.2.7\helpers\pydev\pydevd.py" --multiproc --qt-support=auto --client 127.0.0.1 --port 56120 --file C:/Users/huang/PycharmProjects/gp/manage.py runserver 8000
pydev debugger: process 33272 is connecting

Connected to pydev debugger (build 172.4574.37)
pydev debugger: process 35388 is connecting

Unhandled exception in thread started by <_pydev_bundle.pydev_monkey._NewThreadStartupWithTrace object at 0x00000112CB4EBEB8>
Traceback (most recent call last):
  File "C:\Program Files\JetBrains\PyCharm 2017.2.7\helpers\pydev\_pydev_bundle\pydev_monkey.py", line 589, in __call__
    return self.original_func(*self.args, **self.kwargs)
  File "C:\Users\huang\AppData\Local\Programs\Python\Python36\lib\site-packages\django\utils\autoreload.py", line 227, in wrapper
    fn(*args, **kwargs)
  File "C:\Users\huang\AppData\Local\Programs\Python\Python36\lib\site-packages\django\core\management\commands\runserver.py", line 117, in inner_run
    autoreload.raise_last_exception()
  File "C:\Users\huang\AppData\Local\Programs\Python\Python36\lib\site-packages\django\utils\autoreload.py", line 250, in raise_last_exception
    six.reraise(*_exception)
  File "C:\Users\huang\AppData\Local\Programs\Python\Python36\lib\site-packages\django\utils\six.py", line 685, in reraise
    raise value.with_traceback(tb)
  File "C:\Users\huang\AppData\Local\Programs\Python\Python36\lib\site-packages\django\utils\autoreload.py", line 227, in wrapper
    fn(*args, **kwargs)
  File "C:\Users\huang\AppData\Local\Programs\Python\Python36\lib\site-packages\django\__init__.py", line 27, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "C:\Users\huang\AppData\Local\Programs\Python\Python36\lib\site-packages\django\apps\registry.py", line 116, in populate
    app_config.ready()
  File "C:\Users\huang\PycharmProjects\gp\extra_apps\xadmin\apps.py", line 14, in ready
    self.module.autodiscover()
  File "C:\Users\huang\PycharmProjects\gp\extra_apps\xadmin\__init__.py", line 30, in autodiscover
    from extra_apps.xadmin.views import register_builtin_views
  File "C:\Users\huang\PycharmProjects\gp\extra_apps\xadmin\views\__init__.py", line 3, in 
    from .base import BaseAdminPlugin, BaseAdminView, CommAdminView, ModelAdminView, filter_hook, csrf_protect_m, BaseAdminObject
  File "C:\Users\huang\PycharmProjects\gp\extra_apps\xadmin\views\base.py", line 31, in 
    from xadmin.models import Log
  File "C:\Users\huang\PycharmProjects\gp\extra_apps\xadmin\models.py", line 43, in 
    class Bookmark(models.Model):
  File "C:\Users\huang\AppData\Local\Programs\Python\Python36\lib\site-packages\django\db\models\base.py", line 118, in __new__
    "INSTALLED_APPS." % (module, name)
RuntimeError: Model class xadmin.models.Bookmark doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS.

 

 

 

报错:

"C:\Program Files\JetBrains\PyCharm 2017.2.7\bin\runnerw.exe" D:\Envs\gptest\Scripts\python.exe "C:\Program Files\JetBrains\PyCharm 2017.2.7\helpers\pydev\pydevd.py" --multiproc --qt-support=auto --client 127.0.0.1 --port 58420 --file C:/Users/huang/PycharmProjects/gptest/manage.py runserver 8000
pydev debugger: process 2936 is connecting

Connected to pydev debugger (build 172.4574.37)
pydev debugger: process 19500 is connecting

Watching for file changes with StatReloader
Exception in thread django-main-thread:
Traceback (most recent call last):
  File "c:\users\huang\appdata\local\programs\python\python36\Lib\threading.py", line 916, in _bootstrap_inner
    self.run()
  File "c:\users\huang\appdata\local\programs\python\python36\Lib\threading.py", line 864, in run
    self._target(*self._args, **self._kwargs)
  File "D:\Envs\gptest\lib\site-packages\django\utils\autoreload.py", line 53, in wrapper
    fn(*args, **kwargs)
  File "D:\Envs\gptest\lib\site-packages\django\core\management\commands\runserver.py", line 110, in inner_run
    autoreload.raise_last_exception()
  File "D:\Envs\gptest\lib\site-packages\django\utils\autoreload.py", line 76, in raise_last_exception
    raise _exception[1]
  File "D:\Envs\gptest\lib\site-packages\django\core\management\__init__.py", line 357, in execute
    autoreload.check_errors(django.setup)()
  File "D:\Envs\gptest\lib\site-packages\django\utils\autoreload.py", line 53, in wrapper
    fn(*args, **kwargs)
  File "D:\Envs\gptest\lib\site-packages\django\__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "D:\Envs\gptest\lib\site-packages\django\apps\registry.py", line 114, in populate
    app_config.import_models()
  File "D:\Envs\gptest\lib\site-packages\django\apps\config.py", line 211, in import_models
    self.models_module = import_module(models_module_name)
  File "D:\Envs\gptest\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "", line 978, in _gcd_import
  File "", line 961, in _find_and_load
  File "", line 950, in _find_and_load_unlocked
  File "", line 655, in _load_unlocked
  File "", line 678, in exec_module
  File "", line 205, in _call_with_frames_removed
  File "C:\Users\huang\PycharmProjects\gptest\extra_apps\xadmin\models.py", line 8, in 
    from django.core.urlresolvers import NoReverseMatch, reverse
ModuleNotFoundError: No module named 'django.core.urlresolvers'

解决办法:

C:\Users\huang\PycharmProjects\gptest\extra_apps\xadmin\models.py

# from django.core.urlresolvers import NoReverseMatch, reverse
from django.urls import reverse

 

报错:

"C:\Program Files\JetBrains\PyCharm 2017.2.7\bin\runnerw.exe" D:\Envs\gptest\Scripts\python.exe "C:\Program Files\JetBrains\PyCharm 2017.2.7\helpers\pydev\pydevd.py" --multiproc --qt-support=auto --client 127.0.0.1 --port 58707 --file C:/Users/huang/PycharmProjects/gptest/manage.py runserver 8000
pydev debugger: process 17556 is connecting

Connected to pydev debugger (build 172.4574.37)
pydev debugger: process 21624 is connecting

Watching for file changes with StatReloader
Exception in thread django-main-thread:
Traceback (most recent call last):
  File "c:\users\huang\appdata\local\programs\python\python36\Lib\threading.py", line 916, in _bootstrap_inner
    self.run()
  File "c:\users\huang\appdata\local\programs\python\python36\Lib\threading.py", line 864, in run
    self._target(*self._args, **self._kwargs)
  File "D:\Envs\gptest\lib\site-packages\django\utils\autoreload.py", line 53, in wrapper
    fn(*args, **kwargs)
  File "D:\Envs\gptest\lib\site-packages\django\core\management\commands\runserver.py", line 110, in inner_run
    autoreload.raise_last_exception()
  File "D:\Envs\gptest\lib\site-packages\django\utils\autoreload.py", line 76, in raise_last_exception
    raise _exception[1]
  File "D:\Envs\gptest\lib\site-packages\django\core\management\__init__.py", line 357, in execute
    autoreload.check_errors(django.setup)()
  File "D:\Envs\gptest\lib\site-packages\django\utils\autoreload.py", line 53, in wrapper
    fn(*args, **kwargs)
  File "D:\Envs\gptest\lib\site-packages\django\__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "D:\Envs\gptest\lib\site-packages\django\apps\registry.py", line 114, in populate
    app_config.import_models()
  File "D:\Envs\gptest\lib\site-packages\django\apps\config.py", line 211, in import_models
    self.models_module = import_module(models_module_name)
  File "D:\Envs\gptest\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "", line 978, in _gcd_import
  File "", line 961, in _find_and_load
  File "", line 950, in _find_and_load_unlocked
  File "", line 655, in _load_unlocked
  File "", line 678, in exec_module
  File "", line 205, in _call_with_frames_removed
  File "C:\Users\huang\PycharmProjects\gptest\extra_apps\xadmin\models.py", line 12, in 
    from django.utils.encoding import python_2_unicode_compatible, smart_text
ImportError: cannot import name 'python_2_unicode_compatible'

解决办法:

# from django.utils.encoding import python_2_unicode_compatible, smart_text
from django.utils.encoding import smart_text
from six import python_2_unicode_compatible

报错:

"C:\Program Files\JetBrains\PyCharm 2017.2.7\bin\runnerw.exe" D:\Envs\gptest\Scripts\python.exe "C:\Program Files\JetBrains\PyCharm 2017.2.7\helpers\pydev\pydevd.py" --multiproc --qt-support=auto --client 127.0.0.1 --port 59059 --file C:/Users/huang/PycharmProjects/gptest/manage.py runserver 8000
pydev debugger: process 18776 is connecting

Connected to pydev debugger (build 172.4574.37)
pydev debugger: process 20628 is connecting

Watching for file changes with StatReloader
Exception in thread django-main-thread:
Traceback (most recent call last):
  File "c:\users\huang\appdata\local\programs\python\python36\Lib\threading.py", line 916, in _bootstrap_inner
    self.run()
  File "c:\users\huang\appdata\local\programs\python\python36\Lib\threading.py", line 864, in run
    self._target(*self._args, **self._kwargs)
  File "D:\Envs\gptest\lib\site-packages\django\utils\autoreload.py", line 53, in wrapper
    fn(*args, **kwargs)
  File "D:\Envs\gptest\lib\site-packages\django\core\management\commands\runserver.py", line 110, in inner_run
    autoreload.raise_last_exception()
  File "D:\Envs\gptest\lib\site-packages\django\utils\autoreload.py", line 76, in raise_last_exception
    raise _exception[1]
  File "D:\Envs\gptest\lib\site-packages\django\core\management\__init__.py", line 357, in execute
    autoreload.check_errors(django.setup)()
  File "D:\Envs\gptest\lib\site-packages\django\utils\autoreload.py", line 53, in wrapper
    fn(*args, **kwargs)
  File "D:\Envs\gptest\lib\site-packages\django\__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "D:\Envs\gptest\lib\site-packages\django\apps\registry.py", line 114, in populate
    app_config.import_models()
  File "D:\Envs\gptest\lib\site-packages\django\apps\config.py", line 211, in import_models
    self.models_module = import_module(models_module_name)
  File "D:\Envs\gptest\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "", line 978, in _gcd_import
  File "", line 961, in _find_and_load
  File "", line 950, in _find_and_load_unlocked
  File "", line 655, in _load_unlocked
  File "", line 678, in exec_module
  File "", line 205, in _call_with_frames_removed
  File "C:\Users\huang\PycharmProjects\gptest\extra_apps\xadmin\models.py", line 21, in 
    from xadmin.util import quote
  File "C:\Users\huang\PycharmProjects\gptest\extra_apps\xadmin\util.py", line 7, in 
    from django.forms.forms import pretty_name
ImportError: cannot import name 'pretty_name'

解决办法:

把错误的注释

 

"C:\Program Files\JetBrains\PyCharm 2017.2.7\bin\runnerw.exe" D:\Envs\gptest\Scripts\python.exe "C:\Program Files\JetBrains\PyCharm 2017.2.7\helpers\pydev\pydevd.py" --multiproc --qt-support=auto --client 127.0.0.1 --port 54669 --file C:/Users/huang/PycharmProjects/gptest/manage.py runserver 8000
pydev debugger: process 10444 is connecting

Connected to pydev debugger (build 172.4574.37)
pydev debugger: process 18028 is connecting

Watching for file changes with StatReloader
Exception in thread django-main-thread:
Traceback (most recent call last):
  File "c:\users\huang\appdata\local\programs\python\python36\Lib\threading.py", line 916, in _bootstrap_inner
    self.run()
  File "c:\users\huang\appdata\local\programs\python\python36\Lib\threading.py", line 864, in run
    self._target(*self._args, **self._kwargs)
  File "D:\Envs\gptest\lib\site-packages\django\utils\autoreload.py", line 53, in wrapper
    fn(*args, **kwargs)
  File "D:\Envs\gptest\lib\site-packages\django\core\management\commands\runserver.py", line 110, in inner_run
    autoreload.raise_last_exception()
  File "D:\Envs\gptest\lib\site-packages\django\utils\autoreload.py", line 76, in raise_last_exception
    raise _exception[1]
  File "D:\Envs\gptest\lib\site-packages\django\core\management\__init__.py", line 357, in execute
    autoreload.check_errors(django.setup)()
  File "D:\Envs\gptest\lib\site-packages\django\utils\autoreload.py", line 53, in wrapper
    fn(*args, **kwargs)
  File "D:\Envs\gptest\lib\site-packages\django\__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "D:\Envs\gptest\lib\site-packages\django\apps\registry.py", line 114, in populate
    app_config.import_models()
  File "D:\Envs\gptest\lib\site-packages\django\apps\config.py", line 211, in import_models
    self.models_module = import_module(models_module_name)
  File "D:\Envs\gptest\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "", line 978, in _gcd_import
  File "", line 961, in _find_and_load
  File "", line 950, in _find_and_load_unlocked
  File "", line 655, in _load_unlocked
  File "", line 678, in exec_module
  File "", line 205, in _call_with_frames_removed
  File "C:\Users\huang\PycharmProjects\gptest\extra_apps\xadmin\models.py", line 21, in 
    from xadmin.util import quote
  File "C:\Users\huang\PycharmProjects\gptest\extra_apps\xadmin\util.py", line 24, in 
    from django.contrib.staticfiles.templatetags.staticfiles import static
ModuleNotFoundError: No module named 'django.contrib.staticfiles.templatetags'

解决办法:

将from django.contrib.staticfiles.templatetags.staticfiles import static

替换成:

from django.templatetags.static import static

即可

报错:

"C:\Program Files\JetBrains\PyCharm 2017.2.7\bin\runnerw.exe" D:\Envs\gptest\Scripts\python.exe "C:\Program Files\JetBrains\PyCharm 2017.2.7\helpers\pydev\pydevd.py" --multiproc --qt-support=auto --client 127.0.0.1 --port 55713 --file C:/Users/huang/PycharmProjects/gptest/manage.py runserver 8000
pydev debugger: process 1276 is connecting

Connected to pydev debugger (build 172.4574.37)
pydev debugger: process 5508 is connecting

Watching for file changes with StatReloader
Exception in thread django-main-thread:
Traceback (most recent call last):
  File "c:\users\huang\appdata\local\programs\python\python36\Lib\threading.py", line 916, in _bootstrap_inner
    self.run()
  File "c:\users\huang\appdata\local\programs\python\python36\Lib\threading.py", line 864, in run
    self._target(*self._args, **self._kwargs)
  File "D:\Envs\gptest\lib\site-packages\django\utils\autoreload.py", line 53, in wrapper
    fn(*args, **kwargs)
  File "D:\Envs\gptest\lib\site-packages\django\core\management\commands\runserver.py", line 110, in inner_run
    autoreload.raise_last_exception()
  File "D:\Envs\gptest\lib\site-packages\django\utils\autoreload.py", line 76, in raise_last_exception
    raise _exception[1]
  File "D:\Envs\gptest\lib\site-packages\django\core\management\__init__.py", line 357, in execute
    autoreload.check_errors(django.setup)()
  File "D:\Envs\gptest\lib\site-packages\django\utils\autoreload.py", line 53, in wrapper
    fn(*args, **kwargs)
  File "D:\Envs\gptest\lib\site-packages\django\__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "D:\Envs\gptest\lib\site-packages\django\apps\registry.py", line 122, in populate
    app_config.ready()
  File "C:\Users\huang\PycharmProjects\gptest\extra_apps\xadmin\apps.py", line 14, in ready
    self.module.autodiscover()
  File "C:\Users\huang\PycharmProjects\gptest\extra_apps\xadmin\__init__.py", line 29, in autodiscover
    from xadmin.views import register_builtin_views
  File "C:\Users\huang\PycharmProjects\gptest\extra_apps\xadmin\views\__init__.py", line 3, in 
    from .base import BaseAdminPlugin, BaseAdminView, CommAdminView, ModelAdminView, filter_hook, csrf_protect_m, BaseAdminObject
  File "C:\Users\huang\PycharmProjects\gptest\extra_apps\xadmin\views\base.py", line 20, in 
    from django.utils import six
ImportError: cannot import name 'six'

解决办法 :

from django.utils import six

改成:

import six

 

报错:

"C:\Program Files\JetBrains\PyCharm 2017.2.7\bin\runnerw.exe" D:\Envs\gptest\Scripts\python.exe "C:\Program Files\JetBrains\PyCharm 2017.2.7\helpers\pydev\pydevd.py" --multiproc --qt-support=auto --client 127.0.0.1 --port 55811 --file C:/Users/huang/PycharmProjects/gptest/manage.py runserver 8000
pydev debugger: process 15744 is connecting

Connected to pydev debugger (build 172.4574.37)
pydev debugger: process 16080 is connecting

Watching for file changes with StatReloader
Exception in thread django-main-thread:
Traceback (most recent call last):
  File "c:\users\huang\appdata\local\programs\python\python36\Lib\threading.py", line 916, in _bootstrap_inner
    self.run()
  File "c:\users\huang\appdata\local\programs\python\python36\Lib\threading.py", line 864, in run
    self._target(*self._args, **self._kwargs)
  File "D:\Envs\gptest\lib\site-packages\django\utils\autoreload.py", line 53, in wrapper
    fn(*args, **kwargs)
  File "D:\Envs\gptest\lib\site-packages\django\core\management\commands\runserver.py", line 110, in inner_run
    autoreload.raise_last_exception()
  File "D:\Envs\gptest\lib\site-packages\django\utils\autoreload.py", line 76, in raise_last_exception
    raise _exception[1]
  File "D:\Envs\gptest\lib\site-packages\django\core\management\__init__.py", line 357, in execute
    autoreload.check_errors(django.setup)()
  File "D:\Envs\gptest\lib\site-packages\django\utils\autoreload.py", line 53, in wrapper
    fn(*args, **kwargs)
  File "D:\Envs\gptest\lib\site-packages\django\__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "D:\Envs\gptest\lib\site-packages\django\apps\registry.py", line 122, in populate
    app_config.ready()
  File "C:\Users\huang\PycharmProjects\gptest\extra_apps\xadmin\apps.py", line 14, in ready
    self.module.autodiscover()
  File "C:\Users\huang\PycharmProjects\gptest\extra_apps\xadmin\__init__.py", line 29, in autodiscover
    from xadmin.views import register_builtin_views
  File "C:\Users\huang\PycharmProjects\gptest\extra_apps\xadmin\views\__init__.py", line 5, in 
    from .list import ListAdminView
  File "C:\Users\huang\PycharmProjects\gptest\extra_apps\xadmin\views\list.py", line 18, in 
    from xadmin.util import lookup_field, display_for_field, label_for_field, boolean_icon
ImportError: cannot import name 'label_for_field'

解决办法:

 

报错:

 

# from django.utils.lru_cache import lru_cache
from functools import lru_cache

 

C:\Users\huang\PycharmProjects\gptest\extra_apps\xadmin\views\dashboard.py

报错:

  File "C:\Users\huang\PycharmProjects\gptest\extra_apps\xadmin\views\dashboard.py", line 4, in 
    from django.core.urlresolvers import reverse, NoReverseMatch
ModuleNotFoundError: No module named 'django.core.urlresolvers'

改成:

from django.urls import reverse, NoReverseMatch

 

C:\Users\huang\PycharmProjects\gptest\extra_apps\xadmin\views\website.py

ImportError: cannot import name 'login'

改成:

# from django.contrib.auth.views import login
from django.contrib.auth import login
# from django.contrib.auth.views import logout
from django.contrib.auth import logout

报错
C:\Users\huang\PycharmProjects\gptest\extra_apps\xadmin\plugins\filters.py

"C:\Program Files\JetBrains\PyCharm 2017.2.7\bin\runnerw.exe" D:\Envs\gptest\Scripts\python.exe "C:\Program Files\JetBrains\PyCharm 2017.2.7\helpers\pydev\pydevd.py" --multiproc --qt-support=auto --client 127.0.0.1 --port 56503 --file C:/Users/huang/PycharmProjects/gptest/manage.py runserver 8000
pydev debugger: process 14776 is connecting

Connected to pydev debugger (build 172.4574.37)
pydev debugger: process 14964 is connecting

Watching for file changes with StatReloader
Exception in thread django-main-thread:
Traceback (most recent call last):
  File "c:\users\huang\appdata\local\programs\python\python36\Lib\threading.py", line 916, in _bootstrap_inner
    self.run()
  File "c:\users\huang\appdata\local\programs\python\python36\Lib\threading.py", line 864, in run
    self._target(*self._args, **self._kwargs)
  File "D:\Envs\gptest\lib\site-packages\django\utils\autoreload.py", line 53, in wrapper
    fn(*args, **kwargs)
  File "D:\Envs\gptest\lib\site-packages\django\core\management\commands\runserver.py", line 110, in inner_run
    autoreload.raise_last_exception()
  File "D:\Envs\gptest\lib\site-packages\django\utils\autoreload.py", line 76, in raise_last_exception
    raise _exception[1]
  File "D:\Envs\gptest\lib\site-packages\django\core\management\__init__.py", line 357, in execute
    autoreload.check_errors(django.setup)()
  File "D:\Envs\gptest\lib\site-packages\django\utils\autoreload.py", line 53, in wrapper
    fn(*args, **kwargs)
  File "D:\Envs\gptest\lib\site-packages\django\__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "D:\Envs\gptest\lib\site-packages\django\apps\registry.py", line 122, in populate
    app_config.ready()
  File "C:\Users\huang\PycharmProjects\gptest\extra_apps\xadmin\apps.py", line 14, in ready
    self.module.autodiscover()
  File "C:\Users\huang\PycharmProjects\gptest\extra_apps\xadmin\__init__.py", line 49, in autodiscover
    register_builtin_plugins(site)
  File "C:\Users\huang\PycharmProjects\gptest\extra_apps\xadmin\plugins\__init__.py", line 41, in register_builtin_plugins
    [import_module('xadmin.plugins.%s' % plugin) for plugin in PLUGINS if plugin not in exclude_plugins]
  File "C:\Users\huang\PycharmProjects\gptest\extra_apps\xadmin\plugins\__init__.py", line 41, in 
    [import_module('xadmin.plugins.%s' % plugin) for plugin in PLUGINS if plugin not in exclude_plugins]
  File "D:\Envs\gptest\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "", line 978, in _gcd_import
  File "", line 961, in _find_and_load
  File "", line 950, in _find_and_load_unlocked
  File "", line 655, in _load_unlocked
  File "", line 678, in exec_module
  File "", line 205, in _call_with_frames_removed
  File "C:\Users\huang\PycharmProjects\gptest\extra_apps\xadmin\plugins\filters.py", line 9, in 
    from django.db.models.fields import FieldDoesNotExist
ImportError: cannot import name 'FieldDoesNotExist'

解决办法:

bobby老师说

兼容问题 你的django版本是多少? xadmin是哪里的? django最好使用django2.2 xadmin使用我提供的源码

 好的

报错:

"C:\Program Files\JetBrains\PyCharm 2017.2.7\bin\runnerw.exe" D:\Envs\gptest\Scripts\python.exe "C:\Program Files\JetBrains\PyCharm 2017.2.7\helpers\pydev\pydevd.py" --multiproc --qt-support=auto --client 127.0.0.1 --port 56948 --file C:/Users/huang/PycharmProjects/gptest/manage.py runserver 8000
pydev debugger: process 17928 is connecting

Connected to pydev debugger (build 172.4574.37)
pydev debugger: process 17612 is connecting

Watching for file changes with StatReloader
Exception in thread Thread-6:
Traceback (most recent call last):
  File "c:\users\huang\appdata\local\programs\python\python36\Lib\threading.py", line 916, in _bootstrap_inner
    self.run()
  File "c:\users\huang\appdata\local\programs\python\python36\Lib\threading.py", line 864, in run
    self._target(*self._args, **self._kwargs)
  File "D:\Envs\gptest\lib\site-packages\django\utils\autoreload.py", line 54, in wrapper
    fn(*args, **kwargs)
  File "D:\Envs\gptest\lib\site-packages\django\core\management\commands\runserver.py", line 109, in inner_run
    autoreload.raise_last_exception()
  File "D:\Envs\gptest\lib\site-packages\django\utils\autoreload.py", line 77, in raise_last_exception
    raise _exception[0](_exception[1]).with_traceback(_exception[2])
  File "D:\Envs\gptest\lib\site-packages\django\utils\autoreload.py", line 54, in wrapper
    fn(*args, **kwargs)
  File "D:\Envs\gptest\lib\site-packages\django\__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "D:\Envs\gptest\lib\site-packages\django\apps\registry.py", line 122, in populate
    app_config.ready()
  File "C:\Users\huang\PycharmProjects\gptest\extra_apps\xadmin\apps.py", line 14, in ready
    self.module.autodiscover()
  File "C:\Users\huang\PycharmProjects\gptest\extra_apps\xadmin\__init__.py", line 49, in autodiscover
    register_builtin_plugins(site)
  File "C:\Users\huang\PycharmProjects\gptest\extra_apps\xadmin\plugins\__init__.py", line 43, in register_builtin_plugins
    [import_module('xadmin.plugins.%s' % plugin) for plugin in PLUGINS if plugin not in exclude_plugins]
  File "C:\Users\huang\PycharmProjects\gptest\extra_apps\xadmin\plugins\__init__.py", line 43, in 
    [import_module('xadmin.plugins.%s' % plugin) for plugin in PLUGINS if plugin not in exclude_plugins]
  File "D:\Envs\gptest\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "", line 978, in _gcd_import
  File "", line 961, in _find_and_load
  File "", line 950, in _find_and_load_unlocked
  File "", line 655, in _load_unlocked
  File "", line 678, in exec_module
  File "", line 205, in _call_with_frames_removed
  File "C:\Users\huang\PycharmProjects\gptest\extra_apps\xadmin\plugins\themes.py", line 3, in 
    import httplib2
ModuleNotFoundError: No module named 'httplib2'

解决办法:

pip install httplib2==0.9.2

========

报错:

ModuleNotFoundError: No module named 'requests'

解决办法:

pip install requests

报错:

ModuleNotFoundError: No module named 'import_export'
pip install django-import_export

 

报错:

ModuleNotFoundError: No module named 'DjangoUeditor'
pip install DjangoUeditor==1.8.143

报错:

ModuleNotFoundError: No module named 'widgets'

从 https://github.com/twz915/DjangoUeditor3

下载源码

安装

* 方法一:将github整个源码包下载回家,在命令行运行:
	python setup.py install
* 方法二:使用pip工具在命令行运行(推荐):
    pip install DjangoUeditor

报错:

"C:\Program Files\JetBrains\PyCharm 2017.2.7\bin\runnerw.exe" D:\Envs\gptest\Scripts\python.exe "C:\Program Files\JetBrains\PyCharm 2017.2.7\helpers\pydev\pydevd.py" --multiproc --qt-support=auto --client 127.0.0.1 --port 57736 --file C:/Users/huang/PycharmProjects/gptest/manage.py runserver 8000
pydev debugger: process 15664 is connecting

Connected to pydev debugger (build 172.4574.37)
pydev debugger: process 3268 is connecting

Performing system checks...
Watching for file changes with StatReloader

Exception in thread Thread-6:
Traceback (most recent call last):
  File "c:\users\huang\appdata\local\programs\python\python36\Lib\threading.py", line 916, in _bootstrap_inner
    self.run()
  File "c:\users\huang\appdata\local\programs\python\python36\Lib\threading.py", line 864, in run
    self._target(*self._args, **self._kwargs)
  File "D:\Envs\gptest\lib\site-packages\django\utils\autoreload.py", line 54, in wrapper
    fn(*args, **kwargs)
  File "D:\Envs\gptest\lib\site-packages\django\core\management\commands\runserver.py", line 117, in inner_run
    self.check(display_num_errors=True)
  File "D:\Envs\gptest\lib\site-packages\django\core\management\base.py", line 436, in check
    raise SystemCheckError(msg)
django.core.management.base.SystemCheckError: SystemCheckError: System check identified some issues:

ERRORS:
?: (admin.E408) 'django.contrib.auth.middleware.AuthenticationMiddleware' must be in MIDDLEWARE in order to use the admin application.
?: (admin.E409) 'django.contrib.messages.middleware.MessageMiddleware' must be in MIDDLEWARE in order to use the admin application.
users.Banner.image: (fields.E210) Cannot use ImageField because Pillow is not installed.
	HINT: Get Pillow at https://pypi.org/project/Pillow/ or run command "pip install Pillow".
users.UserProfile.image: (fields.E210) Cannot use ImageField because Pillow is not installed.
	HINT: Get Pillow at https://pypi.org/project/Pillow/ or run command "pip install Pillow".

System check identified 4 issues (0 silenced).

 

C:\Users\huang\PycharmProjects\gptest\gptest\settings.py

改变的地方有3处

①MIDDLEWARE_CLASSES->MIDDLEWARE

②元组()改成列表[]

③'django.contrib.auth.middleware.SessionAuthenticationMiddleware',在Django新版本中删除

 

 

 

=====

 

解决办法:

pip install pillow -i https://pypi.douban.com/simple

 

你可能感兴趣的:(python)