B
B
b_efimenko2014-11-19 12:04:13
Python
b_efimenko, 2014-11-19 12:04:13

Web2py error IntegrityError: foreign key constraint failed how to fix?

There are 2 tables:

db.define_table('category', Field('name'))

db.define_table('books',
                Field('title', requires=IS_NOT_EMPTY('Введите название книги'), label='Название*'),
                Field('author', requires=IS_NOT_EMPTY('Введите автора'), label='Автор*'),
                Field('god', 'integer', label='Год выпуска'),
                Field('number_of_pages', 'integer', label='Количество страниц'),
                Field('languages', label='Язык книги*'),
                Field('category', 'reference category', label='Категория*'),
                Field('description', 'text', label='Описание'),
                Field('oblozhka', 'upload', label='Обложка'),
                Field('book', 'upload', label='Файл книги*', requires=IS_NOT_EMPTY('Загрузите файл книги'))
                )

db.books.languages.requires = IS_IN_SET(['Русский', 'Украинский', 'Другой'], error_message='Выберите язык книги')

As soon as I try to submit the completed form, which is generated from the books database, an error immediately pops up:
IntegrityError: foreign key constraint failed
Please tell me how to fix this... thanks in advance!

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question