Python_Flask_Webapp Select menu doesn't work
<p>I'm learning Flask Web Development this book, I have a function on my page that in the "account" there is a select menu , I can choose the function inside , i.e. change password , or log out.
But it's strange that the select menu doesn't work in the index page, no response when I click the "account" , in others page , for example , below /user/AllenXu page , it works normally .</p>

<pre><code>http://localhost:5000/user/AllenXu
</code></pre>

<p><a href="http://i.stack.imgur.com/tvSay.jpg" rel="nofollow"><img src="http://i.stack.imgur.com/tvSay.jpg" alt="other pages"></a> </p>

<p><strong>But in my index page, u can see it doesn't work.</strong></p>

<p><a href="http://i.stack.imgur.com/LmyCm.jpg" rel="nofollow"><img src="http://i.stack.imgur.com/LmyCm.jpg" alt="index page"></a></p>

<p>What is confusing me is that the select menu code was setting in the base.html which is extends from <strong>bootstrap</strong> template , and other pages extends from the base.html , so actually it should work in every page which extends from base.html.</p>

<p>And actually it does work in <code>http://localhost:5000/user/AllenXu</code></p>

<p>But why it does not work in index page ?</p>

<p>Below is my code information </p>

<p><strong>base.html</strong></p>

<pre><code>{% extends "bootstrap/base.html" %}

{% block title %}Flasky{% endblock %}

{% block head %}
{{ super() }}
&lt;link rel="shortcut icon" href="{{ url_for('static', filename='favicon.ico') }}" type="image/x-icon"&gt;
&lt;link rel="icon" href="{{ url_for('static', filename='favicon.ico') }}" type="image/x-icon"&gt;
&lt;link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='styles.css') }}"&gt;
{% endblock %}





{% block navbar %}
    &lt;div class="navbar navbar-inverse" role="navigation"&gt;
    &lt;div class="container"&gt;
    &lt;div class="navbar-header"&gt;
    &lt;button type="button" class="navbar-toggle"data-toggle="collapse" data-target=".navbar-collapse"&gt;
        &lt;span class="sr-only"&gt;Toggle navigation&lt;/span&gt;
        &lt;span class="icon-bar"&gt;&lt;/span&gt;
        &lt;span class="icon-bar"&gt;&lt;/span&gt;
        &lt;span class="icon-bar"&gt;&lt;/span&gt;
    &lt;/button&gt;
&lt;a class="navbar-brand" href="{{url_for('main.index')}}"&gt;Flasky&lt;/a&gt;
    &lt;/div&gt;

&lt;div class="navbar-collapse collapse"&gt;
    &lt;ul class="nav navbar-nav"&gt;
    &lt;li&gt;&lt;a href="{{url_for('main.index')}}"&gt;Home&lt;/a&gt;&lt;/li&gt;

    {% if current_user.is_authenticated %}
    &lt;li&gt;&lt;a href="{{ url_for('main.user', username=current_user.username) }}"&gt;Profile&lt;/a&gt;
    &lt;/li&gt;
    {% endif %}
    &lt;/ul&gt;

    &lt;ul class="nav navbar-nav navbar-right"&gt;

{% if current_user.is_authenticated %}
                &lt;li class="dropdown"&gt;
                    &lt;a href="#" class="dropdown-toggle" data-toggle="dropdown"&gt;
                        &lt;img src="{{ current_user.gravatar(size=18) }}"&gt;
                        Account &lt;b class="caret"&gt;&lt;/b&gt;
                    &lt;/a&gt;
                    &lt;ul class="dropdown-menu"&gt;
                        &lt;li&gt;&lt;a href="{{ url_for('auth.change_password') }}"&gt;Change Password&lt;/a&gt;&lt;/li&gt;
                        &lt;li&gt;&lt;a href="{{ url_for('auth.change_email_request') }}"&gt;Change Email&lt;/a&gt;&lt;/li&gt;
                        &lt;li&gt;&lt;a href="{{ url_for('auth.logout') }}"&gt;Log Out&lt;/a&gt;&lt;/li&gt;
                    &lt;/ul&gt;
                &lt;/li&gt;
                {% else %}
                &lt;li&gt;&lt;a href="{{ url_for('auth.login') }}"&gt;Log In&lt;/a&gt;&lt;/li&gt;
                {% endif %}
            &lt;/ul&gt;
        &lt;/div&gt;
    &lt;/div&gt;
&lt;/div&gt;

{%endblock%}
{%block content%}
&lt;div class="container"&gt;
    {% for message in get_flashed_messages() %}
    &lt;div class="alert alert-warning"&gt;
        &lt;button type="button" class="close" data-dismiss="alert"&gt;&amp;times;&lt;/button&gt;
        {{ message }}
    &lt;/div&gt;
    {% endfor %}
    {% block page_content %}{% endblock %}
&lt;/div&gt;
{%endblock%}
</code></pre>

<p><strong>My views.py</strong></p>

<pre><code>from datetime import datetime
from flask import render_template,session,redirect,url_for,flash
from . import main
from .forms import NameForm,EditProfileForm,EditProfileAdminForm,PostForm
from .. import db
from ..models import User,Role,Permission,Post
from flask.ext.login import login_required,current_user
from ..decorators import admin_required

@main.route('/',methods=['GET','POST'])
def index():
    form = PostForm()
    if current_user.can(Permission.WRITE_ARTICLES) and form.validate_on_submit():
        post = Post(body = form.body.data,author = current_user._get_current_object())
        db.session.add(post)
        return redirect(url_for('.index'))
    posts = Post.query.order_by(Post.timestamp.desc()).all()
    return render_template('index.html',form = form, posts = posts)



@main.route('/user/&lt;username&gt;')
def user(username):
    user = User.query.filter_by(username = username).first()
    if user is None:
        abort (404)
    return render_template('user.html',user = user)
    enter code here
</code></pre>

<p><strong>my index.html file</strong></p>

<pre><code>{% extends "base.html" %}
{% import "bootstrap/wtf.html" as wtf %}
{% block title %}Flasky{% endblock %}
{% block page_content %}

{% block scripts %}          
{{ super() }}                 
{{ moment.include_moment() }}
{% endblock %}

&lt;div class="page-header"&gt;
    &lt;h1&gt;Hello,
    {% if current_user.is_authenticated%}
    {{ current_user.username }}
    {% else %}
    Stranger!
    {% endif %}
    &lt;/h1&gt;
&lt;/div&gt;

&lt;div&gt;
    {% if current_user.can(Permission.WRITE_ARTICLES) %}
    {{ wtf.quick_form(form) }}
    {% endif %}
&lt;/div&gt;
&lt;ul class = "posts"&gt;
    {% for post in posts %}
    &lt;li class = "post"&gt;
    &lt;div class="profile-thumbnail"&gt;
        &lt;a href = "{{ url_for('.user',username = post.author.username) }}"&gt;
            &lt;img class = "img-rounded profile-thumbnail"
            src = "{{ post.author.gravatar(size = 40) }}"&gt;
        &lt;/a&gt;
&lt;/div&gt;

&lt;div class="post-date"&gt;{{ moment(post.timestamp).fromNow() }}&lt;/div&gt;
&lt;div class="post-author"&gt;
    &lt;a href = "{{ url_for('.user',username = post.author.username) }}"&gt;
    {{ post.author.username }}
    &lt;/a&gt;
    &lt;/div&gt;
    &lt;div class = "post-body"&gt;{{ post.body }}&lt;/div&gt;
    &lt;/li&gt;
    {% endfor %}
&lt;/ul&gt;   
{% endblock %}
</code></pre>

<p>Thanks in advance for helping me !!
If any more information needed , please let me know</p>

<p>Finally , I found the problem which caused this...</p>

<p>because ...in my index.html , I insert the {%block scripts%} inside the {%block page_content%}....</p>

<p>the "block" should be seprarte...if block A is inside block B, the A is useless</p>

<pre><code>{% extends "base.html" %}
{% import "bootstrap/wtf.html" as wtf %}
{% block title %}Flasky{% endblock %}
{% block page_content %}

{% block scripts %}          
{{ super() }}                 
{{ moment.include_moment() }}
{% endblock %}

&lt;div class="page-header"&gt;
    &lt;h1&gt;Hello,
    {% if current_user.is_authenticated%}
    {{ current_user.username }}
    {% else %}
    Stranger!
    {% endif %}
    &lt;/h1&gt;
&lt;/div&gt;
</code></pre>

javascript jquery python html flask