I suspect your asset_id is declared as unique (or was declared as unique, 
then you made a migration but db still thinks it is unique).

On Thursday, 6 December 2012 17:37:10 UTC-6, Kenneth wrote:
>
> Hello,
>
> I have a form created by CRUD with some extra fields. assets_label field 
> is a dropdown consisting of all old labels. Beside that I add an normal 
> text field where user can enter a new label. 
> I have then crud.settings.create_onaccept = insert_assets where I update 
> the label name if there is some text in the textfield. This works great.
>
> The problem comes with crud.settings.update_onaccept = update_assets
> and
> def update_assets(form):
>     if form.request_vars.asset_name_2 != '':
>         row = db(db.assets.asset_id == form.vars.id).update(asset_name = 
> form.request_vars.asset_name_2)
>
> I get an error ticket containg:
> <class '_mysql_exceptions.IntegrityError'> (1062, "Duplicate entry 
> '275-2012-12-07 10:26:41' for key 'asset_id'")
>
>
>  File "/usr/lib/pymodules/python2.6/MySQLdb/cursors.py", line 166, in execute
>     self.errorhandler(self, exc, value)
>   File "/usr/lib/pymodules/python2.6/MySQLdb/connections.py", line 35, in 
> defaulterrorhandler
>     raise errorclass, errorvalue
> IntegrityError: (1062, "Duplicate entry '275-2012-12-07 10:26:41' for key 
> 'asset_id'")
>
>
> Any ideas what I'm doing wrong?
>
>
> Kenneth
>
>
>

-- 



Reply via email to