filter.update

8 views
Skip to first unread message

Luca Bertolotti

unread,
Oct 11, 2019, 4:05:09 PM10/11/19
to Django users
sorry but i have a big problem

I have this

mylist = ['a','b','c']

than Mydbtable.filter(column = value),update(mylist[0]=value)

why update never accept mylist[0] there is a solution?

regards

Adam Mičuda

unread,
Oct 11, 2019, 7:24:29 PM10/11/19
to Django users
Hi,
it is not working, because it is not valid python. Use Mydbtable.filter(column = value).update(**{mylist[0]: value}) instead. And keep in mind that value of mylist[0] (any dict key in general) must meet the some criteria to be valid dict key. See https://wiki.python.org/moin/DictionaryKeys for more information.

Regards
Adam

Dne pátek 11. října 2019 18:05:09 UTC+2 Luca Bertolotti napsal(a):
Reply all
Reply to author
Forward
0 new messages