如何将Django中的对象转换为相应的" select_for_update()"宾语?

时间:2018-03-18 08:55:09

标签: django

是否有更短的实现方式

global _start

section .data
    rows dw 10

section .text
_start:

;it defines how many symbols we have to print
movzx ebx, byte[rows] ; ebx holds number of rows
lea eax,[ebx+3]
imul eax,ebx 
shr eax,1 ; now eax holds number of all symbols
mov edx,eax ; now edx holds number of all symbols, used in print

;prepare pointer
mov ecx,esp
sub ecx,eax ; ecx points on the beginning of the string, used in print

;fill the string by stars
mov eax,edx
shr eax,2
mov ebp, dword '****'
next_star:
    mov [ecx+4*eax],ebp
    dec eax
    jge next_star

;fill the string by '\n'
mov edi,esp
dec edi
mov eax,ebx; in the eax is number of rows
inc eax
next_n:
    mov [edi],byte 0xa
    sub edi,eax
    dec eax
    jg next_n

;print
;mov ecx,esp
mov eax,4;  ;sys_write
mov ebx,1;  ;1 - stdout 
int 80h;

;exit
mov eax,1       ;1 -  sys_exit
xor ebx,ebx     ;0 - return 0
int 80h;
ret

例如,在:

\n

1 个答案:

答案 0 :(得分:1)

缩短这一点的唯一方法是遵循标准做法&导入你的模型,所以做一些像;

from myapp.models import Person


def UpdateAge(instance, new_age):
    with transaction.atomic():
        to_update = Person.objects.select_for_update().get(
            pk=instance.pk
        )
        to_update.age = new_age
        to_update.save()

以下是select_for_update

上的文档