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 

https://flask-admin.readthedocs.org/en/latest/_modules/flask_admin/model/base/#basemodelview.on_model_delete

yours different. miss both self , model.


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

android - Keyboard hides my half of edit-text and button below it even in scroll view -