Reputation:
I'm following this book called: "Flask web development".
When I'm creating the login system he creates then I can an exception at my registration of the blueprint I have made.
Log:
C:\Python27\python.exe "C:/Users/Bo/Google Drev/Privat/HobbyProjekter/Event/manage.py"
Traceback (most recent call last):
File "C:/Users/Bo/Google Drev/Privat/HobbyProjekter/Event/manage.py", line 7, in <module>
app = create_app(os.getenv('FLASK_CONFIG') or 'default')
File "C:\Users\Bo\Google Drev\Privat\HobbyProjekter\Event\app\__init__.py", line 42, in create_app
app.register_blueprint(auth_blueprint, url_prefix='/auth')
File "C:\Python27\lib\site-packages\flask\app.py", line 62, in wrapper_func
return f(self, *args, **kwargs)
File "C:\Python27\lib\site-packages\flask\app.py", line 889, in register_blueprint
blueprint.register(self, options, first_registration)
File "C:\Python27\lib\site-packages\flask\blueprints.py", line 153, in register
deferred(state)
File "C:\Python27\lib\site-packages\flask\blueprints.py", line 172, in <lambda>
s.add_url_rule(rule, endpoint, view_func, **options))
File "C:\Python27\lib\site-packages\flask\blueprints.py", line 76, in add_url_rule
view_func, defaults=defaults, **options)
File "C:\Python27\lib\site-packages\flask\app.py", line 62, in wrapper_func
return f(self, *args, **kwargs)
File "C:\Python27\lib\site-packages\flask\app.py", line 984, in add_url_rule
'existing endpoint function: %s' % endpoint)
AssertionError: View function mapping is overwriting an existing endpoint function: auth.login
The code for where I register my blueprint looks like this:
from .auth import auth as auth_blueprint
app.register_blueprint(auth_blueprint, url_prefix='/auth')
And that code imports from my auth__init__.py :
from flask import Blueprint
auth = Blueprint('auth', __name__)
from . import views
from flask import render_template
from . import auth
@auth.route('/login')
def login():
return render_template('auth/login.html')
At last my view I'm trying to register (just a snippet):
@auth.route('/login', methods=['GET', 'POST'])
def login():
Hope you can help
Upvotes: 3
Views: 5442
Reputation: 2480
You have 2 endpoints called '/login'. Change one of their names. Also the functions can't have the same names either.
Upvotes: 4