question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Incompatibility problem with wtforms 3.0.0a1

See original GitHub issue

FileUploadField seems to be incompatible with wtforms >= 3.0.0a1 The problem is: TypeError: process() got an unexpected keyword argument 'extra_filters' The process function overridden in the FileUploadFile class does not specify ‘extra_filters’ as a keyword argument.

wtforms==2.3.3 works, at least for this issue.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:2
  • Comments:12 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
Oisinscommented, Jan 20, 2022

Looks like the fix has been merged in Oct 2021, but the last release is from Apr 2021. Any chance we can get another release?

1reaction
MikesoWebcommented, Dec 19, 2021

form_extra_fields = { “file_upload”: self.form.FileUploadField() }

при добавлении в class StorageAdminModel(ModelView):

возникает эта ошибка. Как добавить поле file_upload в админку?

Model:

class StorageModel(db.Model): tablename = ‘storage’

id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.Unicode(64))
path = db.Column(db.Unicode(128))
type = db.Column(db.Unicode(3))
create_date = db.Column(db.DateTime, default=datetime.now)

class StorageAdminModel(ModelView): form_extra_fields = { “file_upload”: form.FileUploadField() }

# form_columns = ('create_date', 'path', 'type', 'file_upload')
def _list_thumbnail(self, context, model, name, form_extra_fields):

    column_formatters = {
        'path': self.list_thumbnail
    }
    if not model.path:
        return ''

    url = url_for('static', filename=os.path.join('storage/', model.path))

    if model.type in ['jpg', 'jpeg', 'png', 'svg', 'gif']:
        return Markup('' % url)

    if model.type in ['mp3']:
        return Markup('' % url)



def _change_path_data(self, _form):

    try:
        storage_file = _form.file.data
        form_extra_fields = {
            "file_upload": self.form.FileUploadField()
        }
        if storage_file is not None:
            hash = random.getrandbits(128)
            ext = storage_file.filename.split('.')[-1]
            path = '%s.%s' % (hash, ext)

            storage_file.save(
                os.path.join(create_app().config['STORAGE'], path)
            )

            _form.name.data = _form.name.data or storage_file.filename
            _form.path.data = path
            _form.type.data = ext

            del _form.file

    except Exception as ex:
        pass

    return _form

def edit_form(self, obj=None):
    return self._change_path_data(
        super(StorageAdminModel, self).edit_form(obj)
    )

def create_form(self, obj=None):
    return self._change_path_data(
        super(StorageAdminModel, self).create_form(obj)
    )

TypeError: FileUploadField.process() got an unexpected keyword argument ‘extra_filters’

Read more comments on GitHub >

github_iconTop Results From Across the Web

Changes — WTForms Documentation (3.0.x)
Fix a compatibility issue with SQLAlchemy 2.1 that caused QuerySelectField to fail with ValueError: too many values to unpack .
Read more >
wtforms import could not be resolved - Stack Overflow
When I go to env/Lib/site-packages, I have flask_wtf, wtforms, and WTForms-3.0.1dist-info, and Flask_WTf-1.1.0dev0-py3.10egg-info folders, ...
Read more >
conda-forge - :: Anaconda.org
aiida-abinit, 0.2.0a1, MIT, X, The AiiDA plugin for ABINIT. ... anyqt, 0.2.0, doc · dev, GPL-3.0-or-later, X, X, X, X, PyQt4/PyQt5 compatibility layer....
Read more >
WTForms - PyPI
WTForms 3.0.1 ... WTForms is a flexible forms validation and rendering library for Python web ... Issue tracker: https://github.com/wtforms/wtforms/issues.
Read more >
wtforms | flexible forms validation | Form library - kandi
wtforms has a highly active ecosystem. ... There are 38 open issues and 331 have been closed. ... The latest version of wtforms...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found