#9269: get_or_create having issues
---------------------------------------------------+------------------------
          Reporter:  [EMAIL PROTECTED]            |         Owner:  nobody      
 
            Status:  new                           |     Milestone:  post-1.0   
  
         Component:  Database layer (models, ORM)  |       Version:  1.0        
  
        Resolution:                                |      Keywords:  
get_or_create
             Stage:  Unreviewed                    |     Has_patch:  0          
  
        Needs_docs:  0                             |   Needs_tests:  0          
  
Needs_better_patch:  0                             |  
---------------------------------------------------+------------------------
Old 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/

New 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/

Comment (by kmtracey):

 Reformatted description.

-- 
Ticket URL: <http://code.djangoproject.com/ticket/9269#comment:2>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to