syrusakbary / Flask-SuperAdmin

The best admin interface framework for Flask. With scaffolding for MongoEngine, Django and SQLAlchemy.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Question about changing field type (and default)

vburca opened this issue · comments

Hello,

I have a field that I want to be of type TextArea (in the db it is stored as Unicode string) and that will accept whitespace (basically like a raw text field where I can put new lines and such).

I've been looking around for a while and I can't see to figure it out, sorry...

Also, for a 'created_at' field, I would like to give it a default value so that I don't have to always fill it in. I added this:

class ProjectsModel(model.ModelAdmin):
  session = db.session
  field_args = { 
                  'created_at': { 'default': datetime.datetime.utcnow().strftime("%Y-%m-%d %H:%M:%S") }
               }

but it doesn't seem to do anything...

Thank you,
Vlad

you can fix that at db level.

db.DateTimeField(default=datetime.datetime.utcnow())

👍

hehe

Thank you though! :)