【问题标题】:Django Error - AttributeError: 'CourseOverview' object has no attribute 'start_datetime_text'Django 错误 - AttributeError:“CourseOverview”对象没有属性“start_datetime_text”
【发布时间】:2017-05-14 13:55:07
【问题描述】:

我一直试图让这个主题适用于 Open edX(基于 Django),但我在主管日志中收到了这个错误 -

AttributeError: 'CourseOverview' object has no attribute 'start_datetime_text'

整个错误是这样的 -

5 月 14 日 11:43:36 ip-172-26-15-154 [service_variant=lms][django.request][env:sandbox] 错误 [ip-172-26-15-154 20450] [base.py:256 ] - 内部服务器错误: / 回溯(最近一次通话最后): 文件“/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/core/handlers/base.py”,第 132 行,在 get_response 响应 = Wrapped_callback(request, *callback_args, **callback_kwargs) 文件“/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/utils/decorators.py”,第 145 行,在内部 返回函数(*args,**kwargs) _wrapped_view 中的文件“/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/utils/decorators.py”,第 110 行 response = view_func(request, *args, **kwargs) 包装器中的文件“/edx/app/edxapp/edx-platform/common/djangoapps/util/cache.py”,第 78 行 response = view_func(request, *args, **kwargs) 文件“/edx/app/edxapp/edx-platform/lms/djangoapps/branding/views.py”,第 94 行,在索引中 return student.views.index(request, user=request.user) 文件“/edx/app/edxapp/edx-platform/common/djangoapps/student/views.py”,第 221 行,在索引中 return render_to_response('index.html', context) 文件“/edx/app/edxapp/edx-platform/common/djangoapps/edxmako/shortcuts.py”,第 198 行,在 render_to_response return HttpResponse(render_to_string(template_name, dictionary, context_instance, namespace, request), **kwargs) 文件“/edx/app/edxapp/edx-platform/common/djangoapps/edxmako/shortcuts.py”,第 188 行,在 render_to_string return template.render_unicode(**context_dictionary) 文件“/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/mako/template.py”,第 454 行,在 render_unicode as_unicode=真) _render 中的文件“/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/mako/runtime.py”,第 829 行 **_kwargs_for_callable(callable_, data)) _render_context 中的文件“/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/mako/runtime.py”,第 864 行 _exec_template(继承,lclcontext,args=args,kwargs=kwargs) _exec_template 中的文件“/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/mako/runtime.py”,第 890 行 callable_(context, *args, **kwargs) 文件“/tmp/mako_lms/c11f9c5f254718c770fcf021e95ac093/main.html.py”,第 286 行,在 render_body __M_writer(filters.decode.utf8(self.body())) 文件“/tmp/mako_lms/c11f9c5f254718c770fcf021e95ac093/marvel-theme-eucalyptus/lms/templates/index.html.py”,第 54 行,在 render_body runtime._include_file(context, (courses_list), _template_uri) _include_file 中的文件“/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/mako/runtime.py”,第 752 行 callable_(ctx, **_kwargs_for_include(callable_, context._data, **kwargs)) 文件“/tmp/mako_lms/c11f9c5f254718c770fcf021e95ac093/marvel-theme-eucalyptus/lms/templates/courses_list.html.py”,第 44 行,在 render_body runtime._include_file(context, u'course.html', _template_uri, course=course) _include_file 中的文件“/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/mako/runtime.py”,第 752 行 callable_(ctx, **_kwargs_for_include(callable_, context._data, **kwargs)) 文件“/tmp/mako_lms/c11f9c5f254718c770fcf021e95ac093/marvel-theme-eucalyptus/lms/templates/course.html.py”,第 60 行,在 render_body __M_writer(filters.html_escape(filters.decode.utf8(course.start_datetime_text()))) AttributeError:“CourseOverview”对象没有属性“start_datetime_text”

有问题的文件(给出错误的文件 - course.html.py)在这里 https://pastebin.com/0S79hhDa

【问题讨论】:

  • 您是否有需要运行的数据库迁移?这些通常会导致类似于此的错误。
  • 把你的文件名改成 course.py
  • @Exprator 你确定吗?我认为目录中的所有文件都命名为 [*].html.py 并且其他文件都可以正常工作

标签: python django mako edx


【解决方案1】:

start_datetime_text 方法于 2016 年 11 月 30 日为 removed

您应该使用course.advertised_start。可以看到 course.html 模板的current version

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-12-25
    • 2013-06-29
    • 2014-01-22
    • 1970-01-01
    • 1970-01-01
    • 2021-03-18
    • 2021-11-02
    • 2013-01-21
    相关资源
    最近更新 更多