The following should do:

Item.objects.bulk_create([
    Item(pool_cd=pool_cd.unique_code)
    for pool_cd in pool_cds
])

Le jeudi 4 septembre 2014 12:44:08 UTC-4, James P a écrit :
>
> I forgot to include the code where I set the pool codes to NOTFREE, here 
> is the whole snippet.
>
> code_count=5000
> pool_cds = CodePool.objects.filter(free_indicator=True)[:code_count]
>
>
>         for pool_cd in pool_cds:
>             
>             new_item = Item.objects.create(
>                 pool_cd=pool_cd.unique_code,
>             )
>             new_item.save()
>             
>             
>  cursor = connection.cursor()
>         update_sql = 'update CodePool set free_ind=%s where pool_cd.id in 
> %s'
>         instance_param = ()
>         
>         #Create ridiculously long list of params (5000 items)
>         for pool_cd in pool_cds:
>             instance_param = instance_param + (pool_cd.id,)
>         params = [False, instance_param]
>         rows = cursor.execute(update_sql, params)
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/8c770076-f4da-4514-96dc-b62631efa999%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to