我在一个字典中有两个字典,无法弄清楚如何访问特定值

时间:2017-05-08 16:16:26

标签: python html django

我试着看其他例子,但没有一个帮助我, 我的问题是在常量或视图中的某个地方,我似乎无法从CONSTANTS.PY的登陆页面获取标题的值。请帮我弄清楚我在VIEWS.PY中的调用是怎么回事。

CONSTANTS.PY

videos = {'landing_page': {
    'header': 'What\'s it like to take a class at ?',
    'subheader': ' \"There are students who keep in touch for years after they\'ve taken a language class here.\" Learn more about the   experience and what it means to learn a language with us in the video below. You\'re not just taking a class; you\'re getting an immersive experience and joining a growing community',
    'url': 'https://www.youtube.com/'},
      'private_lesson': {
    'header': 'SEE WHAT A CLASS LOOKS LIKE AND MEET OUR TEACHERS',
    'subheader': ' \"There are students who keep in touch for years after they\'ve taken a language class here.\" Learn more about the  experience and what it means to learn a language with us in the video below. You\'re not just taking a class; you\'re getting an immersive experience and joining a growing community',
    'url': 'https://www.youtube.com/'}}

VIEWS.PY

@render_to('video-section.html')
def video_section(request):
context = {}
context['headerLP'] = c.videos['landing_page']['header']
return context

HTMLFILE

{% load staticfiles %}
<section class="video-section">
  <div class="padded-center-container">
    <h2>{{ headerLP }}</h2>
    <p>"There are students who keep in touch for years after they've 
taken a language class here." Learn more about the he video 
below. You're not just taking a class; you're getting an immersive 
experience and joining a growing community.</p>
  </div>
  <div class="video-wrapper">
    <iframe width="560" height="315" 
src="https://www.youtube.com/" frameborder="0" 
allowfullscreen></iframe>
  </div>
</section>

0 个答案:

没有答案