1

私はフラスコを初めて使用し、フラスコログインを使用して、Google プラスサインインとともにアプリケーションでユーザー認証を管理しようとしています。アプリケーションでフラスコ.ext.ログインを使用していますが、それは私を示しています

ImportError:flask.ext.login という名前のモジュールがありません

ここに私のviews.pyファイルがあります

from google.appengine.api import users
from google.appengine.runtime.apiproxy_errors import CapabilityDisabledError


from flask import request, render_template, flash, url_for, redirect
from flask.ext.login import current_user
import flask,flask.views
from flask_cache import Cache

from application import app
from decorators import login_required, admin_required
from forms import ExampleForm
from models import ExampleModel

class View(flask.views.MethodView):
    def get(self):
        # check if the user is logged in or not
        if not login.current_user.is_authenticated():
            return app.login_manager.unauthorized()
        return flask.render_template('index.html')




class Login(flask.views.MethodView):
    def get(self):
        return None

    def post(self):
        # Create a state token to prevent request forgery.
        # Store it in the session for later validation.
        state = ''.join(random.choice(string.ascii_uppercase + string.digits)
              for x in xrange(32))
        session['state'] = state
        # Set the Client ID, Token State, and Application Name in the HTML while
        # serving it.
        response = make_response(render_template('index.html',CLIENT_ID='1075048200759- 5hunu03e087bha87d48874veh1rvr97f.apps.googleusercontent.com', STATE=state, APPLICATION_NAME='uscore_signin'))
        response.headers['Content-Type']='text/html'
        return response, session

修正方法を教えてください。前の議論に従ったとしても、インポート階層を間違った方法で使用していますか ?

4

1 に答える 1

3

以下が機能しない場合:

from flask.ext.login import current_user

以下を試してください:

from flask_login import current_user

これが新しい規約です。

フラスコ ログインのバージョンを確認するには、ターミナルで次のコマンドを実行します。他のパッケージのバージョンがわかるように名前を変更するだけです。

pip show flask-login
于 2016-06-19T12:08:03.380 に答える