[Flask] Deleting rows from Flask-Admin panel

Anonymous Coder anonymouscodar at gmail.com
Thu Mar 16 05:50:54 EDT 2017


I am not able to delete rows from flask-admin and getting following error:

OperationalError: (_mysql_exceptions.OperationalError) (1048, "Column
'student_id' cannot be null") [SQL: u'UPDATE student_attributes SET
student_id=%s WHERE student_attributes.id = %s'] [parameters: ((None,
1888L), (None, 1889L))]
I am using a fix at but couldn't make it work:

https://gist.github.com/pawl/14e6ca2dcdf0435925af

Will appreciate some help.

My models are:

class StudentProfile(db.Model):
   __tablename__='student_profile'
   packages = relationship('Package', backref=('student_profile',
cascade="all,delete"))
   attributes = relationship("StudentAttribute",
backref=('student_profile', cascade="all,delete"))
    groupsubs = relationship("GroupSubscription",
backref=('student_profile', cascade="all,delete"))
   def __init__(self, **kwargs):
        for key, value in kwargs.items():
            setattr(self, key, value)

class StudentAttribute(db.Model):
    __tablename__ = 'student_attributes'

    student_id = db.Column(db.Integer, ForeignKey('student_profile.id',
ondelete='CASCADE', onupdate='CASCADE'))

class Package(db.Model):
    __tablename__ = 'package'
    student_id = db.Column(db.Integer, ForeignKey('student_profile.id',
ondelete='CASCADE', onupdate='CASCADE'))

class GroupSubscription(db.Model):
    student_id = db.Column(db.Integer, ForeignKey('student_profile.id',
ondelete='CASCADE', onupdate='CASCADE'))
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/flask/attachments/20170316/67eec6d9/attachment.html>


More information about the Flask mailing list