Opened 16 years ago

Last modified 16 years ago

#9269 closed

get_or_create having issues — at Initial Version

Reported by: sholombc@… Owned by: nobody
Component: Database layer (models, ORM) Version: 1.0
Severity: Keywords: get_or_create
Cc: kenkam@…, sholombc@… Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

when i used get_or_create """p, created = Inventory.objects.get_or_create(product = pr, location = lo, storage_type = storagetype)

if created:

p.amount = amount1
p.save()

else:

form.save()"""

it would fail on created, and then it would save the form and make 2 records in the database the second time it would give me a error that it found 2 of the same record

the model and form file: http://dpaste.com/81855/
the product model file: http://dpaste.com/81866/
the view code: http://dpaste.com/81855/

the code that works: http://dpaste.com/81867/

Change History (0)

Note: See TracTickets for help on using tickets.
Back to Top