采纳答案成功!
向帮助你的同学说点啥吧!感谢那些助人为乐的人
本问答主要是集中整理在线教育课程的主要常见问题
xadmin
由于xadmin的最新源码和pypi上xadmin的安装源由于不一致造成了有些学员在源码安装xadmin后会出现一些问题
源码安装xadmin后不能运行,报错 app not load
原因: 课程录制的时候xadmin源码的依赖包和pypi上安装源的依赖包是一致的, 但是后来不一致了
解决方法:
1. https://github.com/sshwsfc/xadmin/blob/master/requirements.txt
对照源码中的依赖包一一安装依赖包
2. 直接运行:
pip install future==0.15.2 httplib2==0.9.2 six==1.10.0 django-import-export>=0.5.1
2. 不能选择xadmin的主题
原因: 主题下载网站的http策略变化了, 导致xadmin源码中下载主题的代码出现bug, 目前为止官方没有修复这个bug
解决方案: https://my.oschina.net/u/2396236/blog/1083251 可以参考这篇文章, 后期如果官方一直不修复这个问题, 我会修改源码然后给大家放到群文件里面
如果还有其他的常见问题没有考虑到, 希望当家帮忙在回复里面指出一下, 谢谢
File "/root/.local/share/virtualenvs/prcmdb-q5TzhByx/lib/python3.6/site-packages/django/utils/html.py", line 394, in <lambda>
klass.__str__ = lambda self: mark_safe(klass_str(self))
File "/root/.local/share/virtualenvs/prcmdb-q5TzhByx/lib/python3.6/site-packages/django/forms/boundfield.py", line 41, in __str__
return self.as_widget()
File "/root/.local/share/virtualenvs/prcmdb-q5TzhByx/lib/python3.6/site-packages/django/forms/boundfield.py", line 127, in as_widget
**kwargs
File "/root/git/prcmdb/prcmdb/extra_apps/xadmin/widgets.py", line 81, in render
'</i></span>%s<span class="input-group-btn"><button class="btn btn-default" type="button">%s</button></span></div></div>' % (input_html[0], _(u'Today'), input_html[1], _(u'Now')))
IndexError: list index out of range
[27/Dec/2019 14:02:00] "GET /xadmin/info/alarm/add/ HTTP/1.1" 500 657659
在添加页面无法添加,报错如上
老师,在model设计那一节Run manage Task的时候控制台报错:
Failed to get real commands on module "Djangostart1": python process died with code 1: Traceback (most recent call last):
File "C:\Users\wb-jrc482833\Envs\test2\lib\site-packages\django\apps\config.py", line 118, in create
cls = getattr(mod, cls_name)
AttributeError: module 'django.contrib' has no attribute 'staticfilesmessage'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "D:\Pycharm\PyCharm 2018.3.3\helpers\pycharm\_jb_manage_tasks_provider.py", line 25, in <module>
django.setup()
File "C:\Users\wb-jrc482833\Envs\test2\lib\site-packages\django\__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "C:\Users\wb-jrc482833\Envs\test2\lib\site-packages\django\apps\registry.py", line 89, in populate
app_config = AppConfig.create(entry)
File "C:\Users\wb-jrc482833\Envs\test2\lib\site-packages\django\apps\config.py", line 123, in create
import_module(entry)
File "C:\Users\wb-jrc482833\Envs\test2\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 965, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'django.contrib.staticfilesmessage'
是什么问题啊
老师,源码安装xadmin,还是会报错
raise AppRegistryNotReady("Apps aren't loaded yet.")
django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet.
这是源码安装依赖包,我已经装了
https://github.com/sshwsfc/xadmin/commit/1cdac79fb95c0ff9efc191fe91f5f54ab7e6a3cf
我安装过的包
在编辑器中准备执行makemigrations时报错不一样
ImportError: No module named xadmin
找不到xadmin,我已经把源码复制到了extra_apps下了
实在找不到原因了
老师,我现在是直接用老师的源码的话,会报错:
控制台报错:
C:\Users\qw\Envs\mxonline\lib\site-packages\DjangoUeditor\urls.py:11: RemovedInDjango110Warning: django.conf.urls.patterns() is deprecated and will be removed in Django 1.10. Update your urlpatterns to be a list of django.conf.urls.url() instances instead.
url(r'^controller/$',get_ueditor_controller)
System check identified no issues (0 silenced).
February 15, 2018 - 20:16:15
Django version 1.9, using settings 'mx_online.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.
在访问127.0.0.1:8000以后控制台的错误是:
Exception happened during processing of request from ('127.0.0.1', 58513)
Traceback (most recent call last):
File "c:\python27\Lib\SocketServer.py", line 596, in process_request_thread
Internal Server Error: /course/detail/10/
Traceback (most recent call last):
File "C:\Users\qw\Envs\mxonline\lib\site-packages\django\core\handlers\base.py", line 149, in get_response
response = self.process_exception_by_middleware(e, request)
File "C:\Users\qw\Envs\mxonline\lib\site-packages\django\core\handlers\base.py", line 147, in get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "C:\Users\qw\Envs\mxonline\lib\site-packages\django\views\generic\base.py", line 68, in view
return self.dispatch(request, *args, **kwargs)
File "C:\Users\qw\Envs\mxonline\lib\site-packages\django\views\generic\base.py", line 88, in dispatch
return handler(request, *args, **kwargs)
File "C:\Users\qw\PycharmProjects\mx_online\apps\courses\views.py", line 57, in get
course = Course.objects.get(id=int(course_id))
File "C:\Users\qw\Envs\mxonline\lib\site-packages\django\db\models\manager.py", line 122, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "C:\Users\qw\Envs\mxonline\lib\site-packages\django\db\models\query.py", line 387, in get
self.model._meta.object_name
DoesNotExist: Course matching query does not exist.
self.finish_request(request, client_address)
File "c:\python27\Lib\SocketServer.py", line 331, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "C:\Users\qw\Envs\mxonline\lib\site-packages\django\core\servers\basehttp.py", line 99, in __init__
super(WSGIRequestHandler, self).__init__(*args, **kwargs)
File "c:\python27\Lib\SocketServer.py", line 652, in __init__
self.handle()
File "C:\Users\qw\Envs\mxonline\lib\site-packages\django\core\servers\basehttp.py", line 164, in handle
self.raw_requestline = self.rfile.readline(65537)
File "c:\python27\Lib\socket.py", line 480, in readline
data = self._sock.recv(self._rbufsize)
error: [Errno 10054]
----------------------------------------
[15/Feb/2018 20:24:43] "GET /course/detail/10/ HTTP/1.1" 500 82671
Traceback (most recent call last):
File "c:\python27\Lib\wsgiref\handlers.py", line 86, in run
----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 58512)
----------------------------------------
self.finish_response()
File "c:\python27\Lib\wsgiref\handlers.py", line 128, in finish_response
self.write(data)
File "c:\python27\Lib\wsgiref\handlers.py", line 212, in write
self.send_headers()
File "c:\python27\Lib\wsgiref\handlers.py", line 270, in send_headers
self.send_preamble()
File "c:\python27\Lib\wsgiref\handlers.py", line 191, in send_preamble
self._write('HTTP/%s %s\r\n' % (self.http_version,self.status))
File "c:\python27\Lib\wsgiref\handlers.py", line 391, in _write
self.stdout.write(data)
File "c:\python27\Lib\socket.py", line 328, in write
self.flush()
File "c:\python27\Lib\socket.py", line 307, in flush
self._sock.sendall(view[write_offset:write_offset+buffer_size])
error: [Errno 10054]
[15/Feb/2018 20:24:43] "GET /course/detail/10/ HTTP/1.1" 500 59
Traceback (most recent call last):
File "c:\python27\Lib\SocketServer.py", line 596, in process_request_thread
self.finish_request(request, client_address)
File "c:\python27\Lib\SocketServer.py", line 331, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "C:\Users\qw\Envs\mxonline\lib\site-packages\django\core\servers\basehttp.py", line 99, in __init__
super(WSGIRequestHandler, self).__init__(*args, **kwargs)
File "c:\python27\Lib\SocketServer.py", line 654, in __init__
self.finish()
File "c:\python27\Lib\SocketServer.py", line 713, in finish
self.wfile.close()
File "c:\python27\Lib\socket.py", line 283, in close
self.flush()
File "c:\python27\Lib\socket.py", line 307, in flush
self._sock.sendall(view[write_offset:write_offset+buffer_size])
error: [Errno 10054]
Internal Server Error: /
Traceback (most recent call last):
File "C:\Users\qw\Envs\mxonline\lib\site-packages\django\core\handlers\base.py", line 149, in get_response
response = self.process_exception_by_middleware(e, request)
File "C:\Users\qw\Envs\mxonline\lib\site-packages\django\core\handlers\base.py", line 147, in get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "C:\Users\qw\Envs\mxonline\lib\site-packages\django\views\generic\base.py", line 68, in view
return self.dispatch(request, *args, **kwargs)
File "C:\Users\qw\Envs\mxonline\lib\site-packages\django\views\generic\base.py", line 88, in dispatch
return handler(request, *args, **kwargs)
File "C:\Users\qw\PycharmProjects\mx_online\apps\users\views.py", line 338, in get
'course_orgs':course_orgs
File "C:\Users\qw\Envs\mxonline\lib\site-packages\django\shortcuts.py", line 67, in render
template_name, context, request=request, using=using)
File "C:\Users\qw\Envs\mxonline\lib\site-packages\django\template\loader.py", line 96, in render_to_string
template = get_template(template_name, using=using)
File "C:\Users\qw\Envs\mxonline\lib\site-packages\django\template\loader.py", line 32, in get_template
return engine.get_template(template_name, dirs)
File "C:\Users\qw\Envs\mxonline\lib\site-packages\django\template\backends\django.py", line 40, in get_template
return Template(self.engine.get_template(template_name, dirs), self)
File "C:\Users\qw\Envs\mxonline\lib\site-packages\django\template\engine.py", line 190, in get_template
template, origin = self.find_template(template_name, dirs)
File "C:\Users\qw\Envs\mxonline\lib\site-packages\django\template\engine.py", line 157, in find_template
name, template_dirs=dirs, skip=skip,
File "C:\Users\qw\Envs\mxonline\lib\site-packages\django\template\loaders\base.py", line 40, in get_template
contents = self.get_contents(origin)
File "C:\Users\qw\Envs\mxonline\lib\site-packages\django\template\loaders\filesystem.py", line 25, in get_contents
return fp.read()
File "C:\Users\qw\Envs\mxonline\lib\codecs.py", line 314, in decode
(result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf8' codec can't decode byte 0xbf in position 44: invalid start byte
[15/Feb/2018 20:24:44] "GET / HTTP/1.1" 500 135813
请问老师这是什么原因?我实在是不会呢。之前跟着视频,敲到第八章。然后中间遇到好多问题,时间拖得有点长,于是一着急就想试试直接用源码就遇到这个问题。老师能看出是什么问题吗?请老师解答。
除夕快乐,谢谢老师。
C:\Users\qw>workon mxonline (mxonline) C:\Users\qw>pip list DEPRECATION: The default format will switch to columns in the future. You can use --format=(legacy|columns) (or define a format=(legacy|columns) in your pip.conf under the [list] section) to disable this warning. certifi (2018.1.18) chardet (3.0.4) diff-match-patch (20121119) Django (1.9) django-crispy-forms (1.6.1) django-formtools (1.0) django-import-export (0.7.0) django-pure-pagination (0.3.0) django-simple-captcha (0.4.6) DjangoUeditor (1.8.143) et-xmlfile (1.0.1) future (0.16.0) httplib2 (0.9.2) idna (2.6) jdcal (1.3) MySQL-python (1.2.5) odfpy (1.3.6) openpyxl (2.4.9) Pillow (3.4.2) pip (9.0.1) PyYAML (3.12) requests (2.18.4) setuptools (38.4.0) six (1.11.0) tablib (0.12.1) unicodecsv (0.14.1) urllib3 (1.22) wheel (0.30.0) xlrd (1.1.0) xlwt (1.3.0)
登录后可查看更多问答,登录/注册