I've deleted the db but error still remains ...


Il giorno lunedì 28 gennaio 2013 16:32:10 UTC+1, Massimo Di Pierro ha 
scritto:
>
> I think your problem is corrupted data. You have "Pippo Pippo" in a field 
> that is either integer or reference. This can happen with sqlite if you 
> change a field type. Delete the database and start again. I do not think 
> there is anything wrong with your code.
>
> On Sunday, 27 January 2013 15:51:33 UTC-6, Ivan Gazzola wrote:
>>
>> Il giorno giovedì 24 gennaio 2013 18:56:59 UTC+1, Massimo Di Pierro ha 
>> scritto:
>>
>>>
>>> db.Relation.name.widget=SQLFORM.widgets.autocomplete(request,db.Person,id_field=
>>> db.Person.id <http://db.person.id/>)
>>>
>>> db.Relation.contact.widget=SQLFORM.widgetsre.autocomplete(request,db.Person,id_field=
>>> db.Person.id <http://db.person.id/>)
>>>
>>> should be
>>>
>>>
>>> db.Relation.name.widget=SQLFORM.widgets.autocomplete(request,db.Person,name,id_field=
>>> db.Person.id <http://db.person.id/>)
>>> db.Relation.contact.widget=SQLFORM.widgets.autocomplete(request,
>>> db.Person.name,id_field=db.Person.id <http://db.person.id/>)
>>>
>>>
>>
>>
>> I forgot to write "name" in previus post  but the model was ok. Really my 
>> model is more complex:
>>
>> db.define_table('Nominativi',
>>     Field('nome',notnull=True, represent=lambda nome:nome.title()),
>>     Field('categoria',db.Categorie_Nominativi,default='1'),
>>     Field('sesso',requires=IS_NULL_OR(IS_IN_SET(['maschio','femmina']))),
>>     Field('mail',requires=IS_NULL_OR(IS_EMAIL(error_message=T('Inserire 
>> Una Mail Valida')))),
>>     Field('indirizzo'),
>>     Field('localita', label='Località'),
>>     Field('cap',requires=IS_NULL_OR(IS_LENGTH(5,5, 
>> error_message=T('Inserire Un CAP valido')))),
>>     Field('provincia',requires=IS_NULL_OR(IS_IN_SET(Elenco_Province, 
>> zero=T('Selezionare una Provincia')))),
>>     Field('codice_fiscale',length=20),
>>     Field('partita_iva',length=20),
>>     Field('data_di_nascita','date'),
>>     Field('professione'),
>>     Field('padre'),
>>     Field('madre'),
>>     Field('inviato_da'),
>>     Field('id_precendente','integer'),
>>     format=lambda 
>> r:r.nome.title()+'-->'+db.Categorie_Nominativi(r.categoria)['categoria'])
>>
>>
>>
>> db.Nominativi.categoria.requires=IS_IN_DB(db,'Categorie_Nominativi.id','%(categoria)s',zero=None)
>> db.Nominativi.categoria.represent = lambda id,row: row.categoria
>> db.Nominativi.nome.represent = lambda nome,row: nome.title()
>>
>> db.Nominativi.inviato_da.widget=SQLFORM.widgets.autocomplete(request,db.Nominativi.nome)
>>
>>
>> db.define_table('Relazioni',
>>     Field('nominativo',db.Nomiantivi,required=True),
>>     Field('referente',db.Nominativi,required=True))
>>
>> db.Relazioni.nominativo.widget=SQLFORM.widgets.autocomplete(request,db.Nominativi.nome,id_field=
>> db.Nominativi.id)
>>
>> db.Relazioni.referente.widget=SQLFORM.widgets.autocomplete(request,db.Nominativi.nome,id_field=
>> db.Nominativi.id)
>>
>> The error log:
>> <type 'exceptions.ValueError'> invalid literal for int() with base 10: 
>> 'Pippo Pippo'
>> and 'pippo pippo' was the value of 'referente'.
>>
>> If i try a simplified model like that i posted before, i can insert the 
>> new record but the 'contact' value is stored in 'name' field and 'contact' 
>> field is always '0'.
>>
>> db.define_table('Person', Field('name'), format='%(name)s')
>> db.define_table('Relation', Field('name',db.Person), 
>> ('contact',db.Person))
>> db.Relation.name.widget=SQLFORM.widgets.autocomplete(request,
>> db.Person.name,id_field=db.Person.id <http://db.person.id/>)
>> db.Relation.contact.widget=SQLFORM.widgets.autocomplete(request,
>> db.Person.name,id_field=db.Person.id <http://db.person.id/>)
>>
>> I suppose that ajax request lose some data, it would store only the last 
>> call to table Person ...
>>
>

-- 

--- 
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/groups/opt_out.


Reply via email to