我有一个CBV调用一些模型方法(在机器上运行某些进程,并连接到其他网站以检索数据)
class Edit(View:
def get(self, request):
object = Model.objects.get()
object.foo()
return object
def post(self, request):
...how can I get the object here without looking it
up and calling the method again
我想在post方法中再次获取该对象,但我不想再次调用它,因为我不想再次运行该进程。有没有办法可以获得这些信息?它已通过context
答案 0 :(得分:1)
它将是请求的属性(reference)。
toCsv() {
local file=$1 columnHeaders
# Determine the unique list of column headers and
# read them into a Bash array.
IFS=$'\n' read -d '' -ra columnHeaders < <(awk -F: 'seen[$1]++ { exit } { print $1 }' "$file")
# Output the header line.
(IFS=','; echo "${columnHeaders[*]}")
# Append the data lines.
cut -d':' -f2- "$file" | paste -d, $(printf '%.s- ' $(seq ${#columnHeaders[@]}))
}
# Sample invocation
toCsv file > out.csv
视图按以下顺序获取参数:request,position url argument list,named url arugments as dictionary (doc reference):
data = request.POST # python dictionary-like