django+xadmin 在线教育课程常见问题归纳(持续更新中)
来源:5-5 xadmin全局配置
bobby
2017-09-08
本问答主要是集中整理在线教育课程的主要常见问题
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 可以参考这篇文章, 后期如果官方一直不修复这个问题, 我会修改源码然后给大家放到群文件里面
如果还有其他的常见问题没有考虑到, 希望当家帮忙在回复里面指出一下, 谢谢
33回答
-
bobby
提问者
2017-09-30
3. mac环境下安装mysql-python出错:
string index out of range
原因: mysql-python依赖了某些系统库
解决方案: 先运行 brew install mysql 然后运行 xcode-select --install, 然后再重新安装mysql-python或者mysqlclient都行
452019-04-11 -
慕码人5926626
2018-04-29
老師部署到服務器后,进行邮箱注册,出现50x.html(查看日志是超时了)。怎么解决呢 老师。
20 -
幕布斯9381828
2018-10-12
在执行 python manage.py runserver 的时候出错了 no module named 'django.core.urlresolvers' 在网上搜了问题,大部分都是需要改代码,但是没有找到相关的代码。麻烦老师解决下
112018-10-12 -
乔小朝
2018-03-24
O(∩_∩)O
~
10 -
慕码人5926626
2018-02-05
ImportError: No module named validators 出现这个怎么办呢 bobby老师
112018-02-06 -
左手向左3402329
2017-09-22
MARK
10 -
痞子过
2019-12-27
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
在添加页面无法添加,报错如上
00 -
慕瓜0168339
2019-05-10
#主题无法使用的解决方案
我试过 python3.6 + django1.11
找到 xadmin/package/themes.py 下的
def block_top_navmenu函数下
...
if six.PY3:
#content = content.text.decode()
pass
...
注销 decode()00 -
Mad_Man_
2019-04-27
老师,我的xadmin后台系统,有好多功能爆出解码问题,能帮忙看一下么,能加老师的QQ或者微信么,我的QQ是602359834
00 -
weixin_慕粉1025184
2019-04-14
老师你好,可以通过一下您的好友申请吗,有点问题请教您,或者您加我QQ 1024013820
00 -
慕学学生
2019-04-12
老师~之前xadmin用的好好的,但是这次突然就加载不了js了,请问是为什么呢?
012019-04-14 -
慕后端4419857
2019-03-05
老师 您好,请问 xadmin 支持Mongodb数据库吗?
012019-03-07 -
欲影
2019-02-20
老师,在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'
是什么问题啊
012019-02-21 -
天马神风_IU
2018-08-05
老师,我在更新django2.0时出现了没提到过的错误:
原文件中有显示出错,但这是我从老师的github库中下载的最新xadmin文件夹,因此不知道如何修改,网上也没有提到过这个错,请老师帮帮忙!
我查看那个django.contrib.auth.views发现和以前版本的比小了很多。
附带pip安装包版本号:
012018-08-05 -
兔子爱吃草
2018-08-03
老师,有没有py2+dj1.9的源码?github下载不下来,imooc上也没有py2的
022018-08-03 -
慕田峪1130220
2018-07-01
老师,源码安装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下了
实在找不到原因了
022018-10-28 -
KIWI2018
2018-03-26
老师我有问题。
在学习6-9的时候,在debug调试用户注册这一块的时候,不能实现注册的功能。
在用户验证码填写正确的情况下,
中间register_form.is_valid这段进不去,我不知道是什么原因。这一步我之前有做到过,这次重新做,却又不行。请老师指教。
032018-09-12 -
lemonlxn
2018-03-20
老师好,我运行的时候,报NameError: name 'reload' is not defined。于是我按照网上的教材,修改xadmin里面的site.py。改成上图所示,但现在又报 ImportError: cannot import name 'smart_unicode',请问这个该怎么解决?
另外,我的python版本是 3.6的
Django 是 1.11
012018-03-21 -
慕粉3235508
2018-03-02
xadmin无法加载css 文件
012018-03-05 -
KIWI2018
2018-02-15
老师,我现在是直接用老师的源码的话,会报错:
控制台报错:
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
请问老师这是什么原因?我实在是不会呢。之前跟着视频,敲到第八章。然后中间遇到好多问题,时间拖得有点长,于是一着急就想试试直接用源码就遇到这个问题。老师能看出是什么问题吗?请老师解答。
除夕快乐,谢谢老师。
042018-02-22 -
KIWI2018
2018-02-14
老师,我有问题:
老师,我也有NoReverseMatch的这个问题。 具体如下: 这是我在courses.urls.html下的配置
urlpatterns = [ url(r'^list/$', CourseListView.as_view(), name="course_list"),
url(r'^detail/(?P<course_id>\d+)/$', CourseDetailView.as_view(), name="course_detail"),]
在mx_online.urls.py的配置如下:
urlpatterns = [ url(r'^org/', include('organization.urls',namespace="org")),
url(r'^course/', include('courses.urls', namespace="course")),
url(r'^media/(?P<path>.*)$',serve,{"document_root":MEDIA_ROOT}),]
在访问127.0.0.1:8000/course/detail时控制台报错:
[14/Feb/2018 09:12:50] "GET /course/detail/ HTTP/1.1" 404 3615 Not Found: /course/detail/ 在访问course/list时报错: NoReverseMatch: Reverse for 'course_detail' with arguments '('',)' and keyword arguments '{}' not found. 1 pattern(s) tried: [u'course/detail/(?P<course_id>\\d+)/$']
请问老师这是什么问题?
感觉因为这个url配置出问题所以我许多页面都不能正常访问了,像首页,course/list等都不能正常访问
以下是我在网页看到的错误:
NoReverseMatch at /course/list/
Reverse for 'course_detail' with arguments '('',)' and keyword arguments '{}' not found. 1 pattern(s) tried: [u'course/detail/(?P<course_id>\\d+)/$']
012018-02-19 -
慕码人5926626
2018-02-13
老师好,请问在这个网站基础框架上,能否加入类似社区的发表、评论 这一项功能呢。 如下图呢,希望老是可以指点一二。
012018-02-19 -
慕码人5926626
2018-02-08
老师 添加了课程机构,可是在机构里面添加老师时候,不显示机构呢 这是为啥呢 谢谢老师
062018-02-14 -
慕码人5926626
2018-02-06
老师 我的虚拟环境pip包都安装了呢(xadmin源码安装)。可是pycharm却不显示呢(pycharm里面的还是我手动一个个添加的,很疑惑,为啥不同步呢) 如下图:谢谢老师
032018-03-01 -
qq_路在脚下_16
2018-02-05
还有从老师的github上下载的xadmin里面py2里面用的是django.core.urlresolvers
到了py3就变成了from django.urls import reverse
012018-02-06 -
李嘉图principal
2018-01-10
在mkonline_resource 中下载了xadmin 和DjangoUeditor 放在exapp中 运行 migrations 又报:
File "C:\Users\Administrator\Envs\test4\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'xadmin'
这个错 怎么破
012018-01-10 -
bobby
提问者
2018-01-09
有些同学在mac、linux和windows下出现安装mysql-python或者mysqlclient出问题的情况, 大家可以通过pymysql作为django的驱动, 这个安装不容易出错 具体方法可以参考这个 https://stackoverflow.com/questions/34777755/how-to-config-django-using-pymysql-as-driver
022018-09-20 -
從容
2018-01-03
3-4 views.py
from .models import UserMessage
def getform(request):
all_messages = UserMessage.objects.all()
(断点) for message in all_messages:
print message.name
return render(request, 'messageform.html')断点调试djangotest AppRegistryNotReady: Apps aren't loaded yet.
按照github上xadmin依赖安装如下(python2只找到这个解决办法= =):
请问老师我现在该怎么做?
032018-03-12 -
搬铁少年Ai
2017-12-26
主题加载之后,除了default 和 bootstarp,其他的主题布局都会乱掉,老师有遇到这个问题吗?
00 -
网络侦探
2017-12-23
老师,有个简单问题,如果不需要界面和太多功能,是不是直接就用django-admin来做后台开发也没什么问题呢?
012017-12-25 -
XO鸡丝
2017-12-21
可以提供一下 register.html 以及 apps/users.py/views.py 的源码吗。
022018-07-15 -
慕尼黑1295245
2017-12-12
都安装了还是报这个错,
File "C:\Python27\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.
012017-12-12 -
qq_快乐你懂得_0
2017-10-22
bobby老师,在xadmin不能选择主题这个问题,按照以上博客的方法修改了还是没有起作用;不知道什么原因:
1、下载
pip install requests
2、导入
import requests
3、修改
# Block Views
def block_top_navmenu(self, context, nodes):
themes = [
{'name': _(u"Default"), 'description': _(u"Default bootstrap theme"), 'css': self.default_theme},
{'name': _(u"Bootstrap2"), 'description': _(u"Bootstrap 2.x theme"), 'css': self.bootstrap2_theme},
]
select_css = context.get('site_theme', self.default_theme)
if self.user_themes:
themes.extend(self.user_themes)
if self.use_bootswatch:
ex_themes = cache.get(THEME_CACHE_KEY)
if ex_themes:
themes.extend(json.loads(ex_themes))
else:
ex_themes = []
try:
flag=False
if flag:
h = httplib2.Http()
resp, content = h.request("https://bootswatch.com/api/3.json", 'GET', '',
headers={"Accept": "application/json", "User-Agent": self.request.META['HTTP_USER_AGENT']})
if six.PY3:
content = content.decode()
watch_themes = json.loads(content)['themes']
else:
content = requests.get("https://bootswatch.com/api/3.json")
if six.PY3:
content = content.decode()
watch_themes = json.loads(content)['themes']
ex_themes.extend([
{'name': t['name'], 'description': t['description'],
'css': t['cssMin'], 'thumbnail': t['thumbnail']}
for t in watch_themes])
except Exception as e:
print(e)
cache.set(THEME_CACHE_KEY, json.dumps(ex_themes), 24 * 3600)
themes.extend(ex_themes)
nodes.append(loader.render_to_string('xadmin/blocks/comm.top.theme.html', {'themes': themes, 'select_css': select_css}))022017-12-30
相似问题