joegasewicz / flask-file-upload

Easy file uploads for Flask.
MIT License
154 stars 15 forks source link

FileUpload object has no attribute 'Model' #122

Closed Dev-Laurin closed 2 years ago

Dev-Laurin commented 2 years ago

AttributeError: 'FileUpload' object has no attribute 'Model'

@file_upload.Model
class Post(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    ....
    image = file_upload.Column(db)
    image_alt = db.Column(db.String(100))
    ....

    def __repr__(self):
        return '<Post %r>' % self.title 
Dev-Laurin commented 2 years ago

I found the issue. I was initiating the file_upload after I was trying to use it. Not sure how this worked in a previous version.

joegasewicz commented 2 years ago
   # If you require importing your SQLAlchemy models then make sure you import
    # your models after calling `file_upload.init_app(app, db)` or `FileUpload(app, db)`. 
    from .model import * 

There is an issue open for this https://github.com/joegasewicz/flask-file-upload/issues/111