Friday, October 7, 2011

Why can't "directly" change array elements of model objects in Django shell?

I've noticed that this doesn't often work in Django shell...

x = MyModel.objects.all()
x[3].some_field = "new value"
x[3].save()

Rather, I must often do this...

temp = x[3]
temp.some_field = "new value"
temp.save()

*Sometimes* the first works and I don't know why.

Please advise.

Chris

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment