Hello,

You should reference the table with the same name that is created so the 
table sould be like:

db.define_table('governmetFormPages',
                Field('formImage', 'upload'),
                Field('formTitle',requires=IS_NOT_EMPTY()), 
                Field('formName', 'reference governmenttForm
'),migrate=False,fake_migrate=True)

Best regards


El lunes, 3 de julio de 2017, 4:15:18 (UTC-3), mostwanted escribió:
>
> It is the actually code Tony, i just changed it after posting it. The 
> table name was initially *govmntForm* as it is referenced in the 
> *governmetFormPages* table.
>
> On Sunday, July 2, 2017 at 7:48:43 PM UTC+2, Anthony wrote:
>>
>> Not sure if you're showing your actual code, but the table name is 
>> spelled "governmenttForm" (note the extra "t"), and for the field type, you 
>> have "reference govmntForm".
>>
>> Anthony
>>
>> On Sunday, July 2, 2017 at 4:37:22 AM UTC-4, mostwanted wrote:
>>>
>>> Hi guys, i need help, i'm pulling my hairs out over here, i have a 
>>> website where when i'm trying to record an entry i get an error:
>>> <class 'sqlite3.IntegrityError'> FOREIGN KEY constraint failed
>>>
>>>
>>> I have been able to create 2 forms but other attempts to create more 
>>> forms fail!!
>>>
>>>
>>> These are my tables;
>>>
>>>
>>> db.define_table('government',
>>>                 Field('govName', requires=IS_NOT_EMPTY()),
>>>                 Field('tel', requires=IS_NOT_EMPTY()),
>>>                 Field('email', requires=IS_NOT_EMPTY()),
>>>                 format='%(govName)s',  migrate=False,fake_migrate=True)
>>>
>>>
>>> db.define_table('governmenttForm',
>>>                 Field('formImage', 'upload'),
>>>                 Field('filledformImage', 'upload'),
>>>                 Field('formName',requires=IS_NOT_EMPTY()),
>>>                 Field('governmentName', 'reference government'), 
>>>                 format='%(formName)s',migrate=False,fake_migrate=True)
>>>
>>> db.define_table('governmetFormPages',
>>>                 Field('formImage', 'upload'),
>>>                 Field('formTitle',requires=IS_NOT_EMPTY()), 
>>>                 Field('formName', 'reference 
>>> govmntForm'),migrate=False,fake_migrate=True)
>>>
>>>
>>> I am able to create a form for the governmentForm table but when i try 
>>> to load up the pages for governmentFormPages table i get the error
>>> <class 'sqlite3.IntegrityError'> FOREIGN KEY constraint failed 
>>>
>>>
>>> Below is the stack
>>> Error ticket for "formulator" Ticket ID 
>>>
>>> 127.0.0.1.2017-07-02.10-06-22.18c363e3-13c2-47f7-ace4-3692239493c4
>>> <class 'sqlite3.IntegrityError'> FOREIGN KEY constraint failed Version 
>>> web2py™ Version 2.14.6-stable+timestamp.2016.05.10.00.21.47 Traceback 
>>>
>>> 1.
>>> 2.
>>> 3.
>>> 4.
>>> 5.
>>> 6.
>>> 7.
>>> 8.
>>> 9.
>>> 10.
>>> 11.
>>> 12.
>>> 13.
>>> 14.
>>> 15.
>>> 16.
>>>
>>> Traceback (most recent call last):
>>>   File "/home/mostwanted/web2py/gluon/restricted.py", line 227, in 
>>> restricted
>>>     exec ccode in environment
>>>   File 
>>> "/home/mostwanted/web2py/applications/formulator/controllers/appadmin.py" 
>>> <http://127.0.0.1:8000/admin/default/edit/formulator/controllers/appadmin.py>,
>>>  line 703, in <module>
>>>   File "/home/mostwanted/web2py/gluon/globals.py", line 417, in <lambda>
>>>     self._caller = lambda f: f()
>>>   File 
>>> "/home/mostwanted/web2py/applications/formulator/controllers/appadmin.py" 
>>> <http://127.0.0.1:8000/admin/default/edit/formulator/controllers/appadmin.py>,
>>>  line 151, in insert
>>>     if form.accepts(request.vars, session):
>>>   File "/home/mostwanted/web2py/gluon/sqlhtml.py", line 1746, in accepts
>>>     self.vars.id = self.table.insert(**fields)
>>>   File "/home/mostwanted/web2py/gluon/packages/dal/pydal/objects.py", line 
>>> 726, in insert
>>>     ret = self._db._adapter.insert(self, self._listify(fields))
>>>   File "/home/mostwanted/web2py/gluon/packages/dal/pydal/adapters/base.py", 
>>> line 746, in insert
>>>     raise e
>>> IntegrityError: FOREIGN KEY constraint failed
>>>
>>>
>>> Please help me, i dont know what to do, i have tried to look for 
>>> solutions online but i just dont understand them, may someone please give 
>>> me light on what i'm doing wrong.
>>>
>>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to