[web2py] Re: Foreign key constraint failed

2017-01-11 Thread pilzsuppe
Hello Anthony, my eintrag_erstellen is a html view:

--

{{extend 'layout.html'}}

{{block header}}
 
{{end}}


Erstelle einen neuen Beitrag über das Thema {{=category.name.title()}}



{{=form}}

--

I gain access this way: 
1. I click this button in another view:

--

Neuer Eintrag

--

which leads me to this:

--

def erstellen():
rows = db(db.category).select()
form = SQLFORM(db.eintrag).process(next='eintrag_betrachten/[id]')
return locals()

--

and this view:

--

{{extend 'layout.html'}}

{{block header}}
 
{{end}}


Profil | Ausloggen | Mitgliedschaft beenden



Eintrag erstellen


{{for category in rows:}}


{{=A(category.name.title(),_class='btn',_href=URL('eintrag_erstellen',args=category.name))}}

{{pass}}

--

There all my categories got listed in a single button. When I click on one 
of them, I gain acces to my eintrag_erstellen view

-- 
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.


[web2py] Foreign key constraint failed

2017-01-10 Thread pilzsuppe
Good day,

I was following the video tutorial of Massimo, just as other users here. 
But when I want to submit a post I get the error
>IntegrityError: foreign key constraint failed<

---My db.py:---

db.define_table('category', 
Field('name',requires=IS_IN_SET(['suess','sauer','frostig','fruchtig','schokoladig','einfach_lecker'])))

db.define_table('eintrag',
Field('category','reference category',writable=False),
Field('eintragId', 'integer',readable=False,writable=False),
Field('standort','string',requires=IS_NOT_EMPTY()),
Field('laden','string'),
Field('eis', 
requires=IS_IN_SET(['Schokolade','Vanille','Erdbeere','Pistazie','Banane','Andere',])),
Field('eigenschaft','text'),
auth.signature)

---My default.py:---

def get_category():
category_name = request.args(0)
category = db.category(name=category_name)
if not category:
session.flash = 'Element nicht gefunden'
redirect(URL('eis'))
return category

def eintrag_erstellen():
category = get_category()
db.eintrag.category.default = category.id
form = SQLFORM(db.eintrag).process(next='eintrag_betrachten/[id]')
return locals()

---My view:---

{{extend 'layout.html'}}

{{block header}}
 
{{end}}


Erstelle einen neuen Beitrag über das Thema {{=category.name.title()}}




{{=form}}



-
this is exactly the same code as massimo used (just with german words 
instead of english ones, but this does not cause the problem). I already 
found threads about this problem and their solution was to create tabled 
with appadmin. I did. But the same error. 
If I delete the row in default.py >db.eintrag.category.default = 
category.id< everything works just fine but the fact that the category 
field is "None". 

-- 
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.