助けが必要だということがありました。私のdjangoアプリケーションには、次のコードがあります:
from django.template import Context
render_dict = {'scan': oval_scan, 'user': user, 'vulns': oval_vulns, 'asset_vulns': asset_vulns}
report_html = get_template('oval_report.html').render(Context(render_dict))
ただし、djangoは次のエラーを出しました:
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 111, in get_response
response = callback(request, *callback_args, **callback_kwargs)
File "/home/nopsec/nopsecvrm/apps/pegasus/views.py", line 2359, in ovalReport
report_html = get_template('pegasus/oval_report.html').render(Context(render_dict))
File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 121, in render
context.render_context.push()
AttributeError: 'Context' object has no attribute 'render_context'
間違って使用された別のインポートパッケージに別の場所があるため、このエラーに一度遭遇したことを思い出したContext
ので、コードを次のように変更します(非常に醜いですが動作します):
import django
render_dict = {'scan': oval_scan, 'user': user, 'vulns': oval_vulns, 'asset_vulns': asset_vulns}
report_html = get_template('report.html').render(django.template.Context(render_dict))
Context
私の質問は次のとおりです。トレースバックエラーを見て、djangoが誤って使用したものをどのように判断できますか? どうすればこの状況を解決できますか? ありがとう。