On 10 sep, 11:57, David <[email protected]> wrote:
> if I do
>
> nothing = ModelName.objects.none()
> nothing.update(status='new_status')
>
> Then all of my objects in the database get updated. I would expect
> nothing to happen but... is an empty QuerySet really supposed to apply
> changes like that?

Don't have this behaviour here. Are you sure your ModelName.objects is
the default manager ?


br...@bruno:/var/www/myproject/$ ./manage.py shell
Python 2.6.2 (release26-maint, Apr 19 2009, 01:56:41)
[GCC 4.3.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> from reservations.models import *
>>> print "\n".join("%s - %s" % (str(r.id), r.status) for r in 
>>> Reservation.objects.all())
1 - nouveau
2 - nouveau
3 - nouveau
4 - nouveau
5 - nouveau
6 - nouveau
7 - nouveau
8 - nouveau
9 - nouveau
10 - nouveau
11 - nouveau
12 - nouveau
13 - nouveau
14 - nouveau
15 - nouveau
16 - nouveau
17 - nouveau
18 - nouveau
19 - nouveau
20 - nouveau
21 - nouveau
>>> Reservation.objects.none()
[]
>>> Reservation.objects.none().update
<bound method EmptyQuerySet.update of []>
>>> Reservation.objects.none().update(status='encours')
0
>>> print "\n".join("%s - %s" % (str(r.id), r.status) for r in 
>>> Reservation.objects.all())
1 - nouveau
2 - nouveau
3 - nouveau
4 - nouveau
5 - nouveau
6 - nouveau
7 - nouveau
8 - nouveau
9 - nouveau
10 - nouveau
11 - nouveau
12 - nouveau
13 - nouveau
14 - nouveau
15 - nouveau
16 - nouveau
17 - nouveau
18 - nouveau
19 - nouveau
20 - nouveau
21 - nouveau
>>>


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

Reply via email to