有一个模型
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim FilePath As String = Application.StartupPath & "\npcli.exe"
Using MsiFile As New FileStream(FilePath, FileMode.Create)
MsiFile.Write(My.Resource.npcli, 0, My.Resource.npcli.Length)
End Using
Dim x As String = "/driver /add 192.168.1.1 /port 1 /com 4"
Process.Start(FilePath, x)
End Sub
flask-admin为此模型生成此表单 click here
问题:当我创建新记录时,url字段为空。
答案 0 :(得分:1)
您可以覆盖flask-admin保存方法,如下所示:
class Article(db.Model, Base):
id = db.Column(db.Integer(), primary_key=True)
title = db.Column(db.String())
description = db.Column(db.Text())
url = db.Column(db.String())
created_on = db.Column(db.DateTime(), server_default=db.func.now())
updated_on = db.Column(db.DateTime(), server_default=db.func.now(), onupdate=db.func.now())
author = db.Column(db.Integer(), db.ForeignKey('user.id'))
category = db.Column(db.Integer(), db.ForeignKey('category.id'))
def save(self, *args, **kwargs):
self.url = slugify(self.title)
return super(Article, self).save(*args, **kwargs)