Closed vToMy closed 8 years ago
Do you have a stack trace?
Here you go:
Traceback (most recent call last):
File "C:\Users\vToMy\AppData\Local\Programs\Python\Python35-32\lib\site-packages\flask\app.py", line 1817, in wsgi_app
response = self.full_dispatch_request()
File "C:\Users\vToMy\AppData\Local\Programs\Python\Python35-32\lib\site-packages\flask\app.py", line 1477, in full_dispatch_request
rv = self.handle_user_exception(e)
File "C:\Users\vToMy\AppData\Local\Programs\Python\Python35-32\lib\site-packages\flask\app.py", line 1381, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "C:\Users\vToMy\AppData\Local\Programs\Python\Python35-32\lib\site-packages\flask\_compat.py", line 33, in reraise
raise value
File "C:\Users\vToMy\AppData\Local\Programs\Python\Python35-32\lib\site-packages\flask\app.py", line 1475, in full_dispatch_request
rv = self.dispatch_request()
File "C:\Users\vToMy\AppData\Local\Programs\Python\Python35-32\lib\site-packages\flask\app.py", line 1461, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "C:\Users\vToMy\PycharmProjects\flask-admin\flask_admin\base.py", line 68, in inner
return self._run_view(f, *args, **kwargs)
File "C:\Users\vToMy\PycharmProjects\flask-admin\flask_admin\base.py", line 367, in _run_view
return fn(self, *args, **kwargs)
File "C:\Users\vToMy\PycharmProjects\flask-admin\flask_admin\contrib\fileadmin.py", line 961, in action_view
return self.handle_action()
File "C:\Users\vToMy\PycharmProjects\flask-admin\flask_admin\actions.py", line 121, in handle_action
url = get_redirect_target() or self.get_url('.index_view')
File "C:\Users\vToMy\PycharmProjects\flask-admin\flask_admin\base.py", line 389, in get_url
return url_for(endpoint, **kwargs)
File "C:\Users\vToMy\AppData\Local\Programs\Python\Python35-32\lib\site-packages\flask\helpers.py", line 312, in url_for
return appctx.app.handle_url_build_error(error, endpoint, values)
File "C:\Users\vToMy\AppData\Local\Programs\Python\Python35-32\lib\site-packages\flask\app.py", line 1641, in handle_url_build_error
reraise(exc_type, exc_value, tb)
File "C:\Users\vToMy\AppData\Local\Programs\Python\Python35-32\lib\site-packages\flask\_compat.py", line 33, in reraise
raise value
File "C:\Users\vToMy\AppData\Local\Programs\Python\Python35-32\lib\site-packages\flask\helpers.py", line 305, in url_for
force_external=external)
File "C:\Users\vToMy\AppData\Local\Programs\Python\Python35-32\lib\site-packages\werkzeug\routing.py", line 1678, in build
raise BuildError(endpoint, values, method)
werkzeug.routing.BuildError: ('fileuploadmodelview.index_view', {}, None)
This is how I created the instance:
FileAdmin(upload_dir, '/static/', url='/upload', name='Upload Files', category=category)
Figured out the cause - FileAdmin defines the index endpoint as ".index" where as the action tries to redirect to ".index_view". Here is a patch if anyone finds it useful:
def get_url(self, endpoint, **kwargs):
if endpoint == '.index_view':
endpoint = '.index'
return super().get_url(endpoint, **kwargs)
I recommend just changing the ".index" to ".index_view" in FileAdmin to follow the convention.
When adding a custom action (via @ action) in a custom FileAdmin view - after the action finishes the redirection is broken (500 internal server error). Not sure what's causing this yet.