python - Can someone help as to why I am getting an argument error flask on_model_delete callback? -
i trying implement callback when delete employee has associated image, on_model_delete
callback remove local system.
this code:
class employeeview(modelview): form = employeeform def _list_thumbnail(view, context, model, name): if not model.photo: return '' return markup('<img height="100" width="100" src="%s">' % url_for('static', filename= 'images/' + model.photo.image)) column_formatters = { 'photo': _list_thumbnail } form_extra_fields = { 'photo': imageuploadfield('image', base_path=app.config['upload_folder']) } def on_model_delete(): if app.config['use_s3']: pass else: os.remove(app.config['upload_folder'] + model.photo.image) def is_accessible(self): return flask_login.current_user.is_authenticated
the methods defined , variables dictionaries parameters flask-admin
provides customizing views. on_model_change
callback provided flask_admin. documentation here enter link description here
here i've implemented , errors i've received them:
on_model_delete(model) ---------> typeerror: on_model_delete() takes 1 argument (2 given) on_model_delete(model.photo) -----------> syntaxerror: invalid syntax on_model_delete() -----------> typeerror: on_model_delete() takes no arguments (2 given)
i'm confused, depending on put argument list keeps changing. when put nothing says 2 given. when put 1 argument says 2 given. going on?
according docs correct method definition.
def on_model_delete(self, model): pass
yours different. miss both self
, model
.
Comments
Post a Comment