If you benefit from web2py hope you feel encouraged to pay it forward by contributing back to society in whatever form you choose!

Hi!

I tried to create this table: (db.py)

db.define_table('navbar',
                Field("title", "string"),
                Field("url", "string", requires=IS_EMPTY_OR(IS_URL())),
                Field("cont", label="Controller"),
                Field("func", label="Function"),
                Field("args", label="Arguments"),
                Field("sortable", "integer"),
                Field("parent_id", "reference navbar"),
                format="%(title)s",
                )

 

sql generated:

CREATE TABLE navbar_admin(
    id INT AUTO_INCREMENT NOT NULL,
    title VARCHAR(512),
    url VARCHAR(512),
    cont VARCHAR(512),
    func VARCHAR(512),
    args VARCHAR(512),
    sortable INT,
    parent_id INT, INDEX parent_id__idx (parent_id), FOREIGN KEY (parent_id) REFERENCES navbar (id) ON DELETE CASCADE,
    PRIMARY KEY(id)
) ENGINE=InnoDB CHARACTER SET utf8;
faked!

mysql error:  Cannot add foreign key constraint

any solution?

 

Answers (0)

Comments (0)

Related content


Hosting graciously provided by:
Python Anywhere