Last active
April 11, 2017 12:41
-
-
Save avdata99/f5d8e9844e2308acc48e35318cadd73f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.db.models import F, Func, Value | |
# todos | |
MyModel.objects.all() | |
.update( | |
campo_a_reemplazar=Func( | |
F('campo_a_reemplazar_u_otro'), | |
Value('txt_buscar'), | |
Value('txt_reemplazar'), | |
function='replace')) | |
# algunos filtrando | |
MyModel.objects.filter(campo='algo') | |
.update( | |
campo_a_reemplazar=Func( | |
F('campo_a_reemplazar_u_otro'), | |
Value('txt_buscar'), | |
Value('txt_reemplazar'), | |
function='replace')) | |
# algunos excluyendo | |
MyModel.objects.exclude(alicuota='') | |
.update( | |
campo_a_reemplazar=Func( | |
F('campo_a_reemplazar_u_otro'), | |
Value('txt_buscar'), | |
Value('txt_reemplazar'), | |
function='replace')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment