{"action":"opened","issue":{"url":"https://api.github.com/repos/flask-admin/flask-admin/issues/928","labels_url":"https://api.github.com/repos/flask-admin/flask-admin/issues/928/labels{/name}","comments_url":"https://api.github.com/repos/flask-admin/flask-admin/issues/928/comments","events_url":"https://api.github.com/repos/flask-admin/flask-admin/issues/928/events","html_url":"https://github.com/flask-admin/flask-admin/issues/928","id":93109916,"number":928,"title":"Inline model creation fails when relationship has cascade=\"delete\" set","user":{"login":"aebrahim","id":1380168,"avatar_url":"https://avatars.githubusercontent.com/u/1380168?v=3","gravatar_id":"","url":"https://api.github.com/users/aebrahim","html_url":"https://github.com/aebrahim","followers_url":"https://api.github.com/users/aebrahim/followers","following_url":"https://api.github.com/users/aebrahim/following{/other_user}","gists_url":"https://api.github.com/users/aebrahim/gists{/gist_id}","starred_url":"https://api.github.com/users/aebrahim/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aebrahim/subscriptions","organizations_url":"https://api.github.com/users/aebrahim/orgs","repos_url":"https://api.github.com/users/aebrahim/repos","events_url":"https://api.github.com/users/aebrahim/events{/privacy}","received_events_url":"https://api.github.com/users/aebrahim/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-07-05T13:04:13Z","updated_at":"2015-07-05T13:04:13Z","closed_at":null,"body":"This is the likely cause for #759 \r\n\r\nThis example script recreates the problem:\r\n```python\r\nfrom sqlalchemy import create_engine\r\nfrom sqlalchemy.ext.declarative import declarative_base\r\nfrom sqlalchemy.orm import sessionmaker, relationship, scoped_session\r\nfrom sqlalchemy import Column, Integer, String, ForeignKey\r\n\r\nfrom flask import Flask\r\nfrom flask_admin import Admin\r\nfrom flask_admin.contrib.sqla import ModelView\r\n\r\nengine = create_engine(\"sqlite:///data.db\")\r\nBase = declarative_base(bind=engine)\r\nSession = scoped_session(sessionmaker(bind=engine))\r\n\r\n\r\nclass Basket(Base):\r\n    __tablename__ = \"baskets\"\r\n\r\n    id = Column(Integer, primary_key=True)\r\n    recipient = Column(String(10))\r\n    apples = relationship(\"Apple\", cascade=\"delete\")\r\n\r\n\r\nclass Apple(Base):\r\n    __tablename__ = \"apples\"\r\n\r\n    id = Column(Integer, primary_key=True)\r\n    basket_id = Column(Integer, ForeignKey(\"baskets.id\", onupdate=\"CASCADE\",\r\n                                           ondelete=\"CASCADE\"), nullable=False)\r\n    type = Column(String(10))\r\n    basekets = relationship(Basket)\r\n\r\n\r\nBase.metadata.create_all()\r\n\r\n\r\nsession = Session()\r\n\r\n\r\nclass BasketView(ModelView):\r\n    inline_models = [Apple]\r\n\r\napp = Flask(__name__)\r\napp.config[\"SECRET_KEY\"] = \"12345\"\r\n\r\nadmin = Admin(app, name=\"demo\", template_mode=\"bootstrap3\")\r\nadmin.add_view(BasketView(Basket, session))\r\nadmin.add_view(ModelView(Apple, session))\r\n\r\nif __name__ == \"__main__\":\r\n    app.run(host=\"0.0.0.0\", debug=True)\r\n```\r\n\r\nEntering data into the form:\r\n![image](https://cloud.githubusercontent.com/assets/1380168/8511789/ab19e846-22da-11e5-9c11-61629f5abf14.png)\r\n\r\nHowever, after hitting \"Save\" they are not actually created.\r\n![image](https://cloud.githubusercontent.com/assets/1380168/8511811/93715084-22db-11e5-9524-5fd8c376c1e5.png)\r\n\r\n\r\nIf I remove the cascade=\"delete\" flag from the relationship, then this works fine.\r\n![image](https://cloud.githubusercontent.com/assets/1380168/8511800/3405178e-22db-11e5-90bc-0fcaad5544f8.png)\r\n"}}