Re: Problem updating data
My first thought is that you didn't call parent save method in you custom save method super(YourClass, self).save(*args, **kwargs) On 26 Sie, 03:59, Karen McNeilwrote: > Thank you Malcolm, you were exactly right! > > I would have never thought of that, but I have a custom save method > and when I commented it out and restarted the app, setting the active > property worked just as expected. Now I just have to figure out what > the hell is wrong with my save method... :-) > > Thank you! > > ~Karen > > On Aug 24, 8:31 pm, Malcolm Box wrote: > > > > > > > > > Instead of counting the inactive, try counting the active ones. If that > > count doesn't go up by one, I'd suspect something's dodgy in your Entry > > model's save() that means it doesn't write successfully to the db. > > > You could debug by doing: > > > from django.db import connection > > connection.queries > > e1.save() > > connection.queries > > > to see what the SQL generated was. > > > Then start looking at your database to see what it's doing. > > > Malcolm > > > On 23 August 2011 23:08, Karen McNeil wrote: > > > > No, that's not the problem. Even if I redo the query now, I still get > > > the same count (see below). And, like I said, the change does not show > > > up in the admin either -- THE VALUE HAS NOT BEEN CHANGED. > > > > This behavior is so unexpected I'm not sure how to even begin trouble- > > > shooting it. > > > > ~Karen > > > > PS -- What's wrong with querying by "active=0"? I did it that way > > > because that's what the admin interface does for filters... is there > > > any difference? > > > > NEW SHELL SESSION FROM TODAY, TESTING SAME THING: > > > > >>> from dictionary.models import Entry > > > >>> entries = Entry.objects.filter(active=False) > > > >>> entries.count() > > > 3642 > > > >>> e1 = entries[0] > > > >>> e1 > > > > > > >>> e1.active > > > False > > > > -- > > > 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+unsubscr...@googlegroups.com. > > > For more options, visit this group at > > >http://groups.google.com/group/django-users?hl=en. > > > -- > > Malcolm Box > > malcolm@gmail.com -- 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+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Problem updating data
Thank you Malcolm, you were exactly right! I would have never thought of that, but I have a custom save method and when I commented it out and restarted the app, setting the active property worked just as expected. Now I just have to figure out what the hell is wrong with my save method... :-) Thank you! ~Karen On Aug 24, 8:31 pm, Malcolm Boxwrote: > Instead of counting the inactive, try counting the active ones. If that > count doesn't go up by one, I'd suspect something's dodgy in your Entry > model's save() that means it doesn't write successfully to the db. > > You could debug by doing: > > from django.db import connection > connection.queries > e1.save() > connection.queries > > to see what the SQL generated was. > > Then start looking at your database to see what it's doing. > > Malcolm > > On 23 August 2011 23:08, Karen McNeil wrote: > > > > > > > > > > > No, that's not the problem. Even if I redo the query now, I still get > > the same count (see below). And, like I said, the change does not show > > up in the admin either -- THE VALUE HAS NOT BEEN CHANGED. > > > This behavior is so unexpected I'm not sure how to even begin trouble- > > shooting it. > > > ~Karen > > > PS -- What's wrong with querying by "active=0"? I did it that way > > because that's what the admin interface does for filters... is there > > any difference? > > > NEW SHELL SESSION FROM TODAY, TESTING SAME THING: > > > >>> from dictionary.models import Entry > > >>> entries = Entry.objects.filter(active=False) > > >>> entries.count() > > 3642 > > >>> e1 = entries[0] > > >>> e1 > > > > >>> e1.active > > False > > > -- > > 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+unsubscr...@googlegroups.com. > > For more options, visit this group at > >http://groups.google.com/group/django-users?hl=en. > > -- > Malcolm Box > malcolm@gmail.com -- 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+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Problem updating data
Instead of counting the inactive, try counting the active ones. If that count doesn't go up by one, I'd suspect something's dodgy in your Entry model's save() that means it doesn't write successfully to the db. You could debug by doing: from django.db import connection connection.queries e1.save() connection.queries to see what the SQL generated was. Then start looking at your database to see what it's doing. Malcolm On 23 August 2011 23:08, Karen McNeilwrote: > No, that's not the problem. Even if I redo the query now, I still get > the same count (see below). And, like I said, the change does not show > up in the admin either -- THE VALUE HAS NOT BEEN CHANGED. > > This behavior is so unexpected I'm not sure how to even begin trouble- > shooting it. > > ~Karen > > PS -- What's wrong with querying by "active=0"? I did it that way > because that's what the admin interface does for filters... is there > any difference? > > > NEW SHELL SESSION FROM TODAY, TESTING SAME THING: > > >>> from dictionary.models import Entry > >>> entries = Entry.objects.filter(active=False) > >>> entries.count() > 3642 > >>> e1 = entries[0] > >>> e1 > > >>> e1.active > False > > -- > 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+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- Malcolm Box malcolm@gmail.com -- 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+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Problem updating data
No, that's not the problem. Even if I redo the query now, I still get the same count (see below). And, like I said, the change does not show up in the admin either -- THE VALUE HAS NOT BEEN CHANGED. This behavior is so unexpected I'm not sure how to even begin trouble- shooting it. ~Karen PS -- What's wrong with querying by "active=0"? I did it that way because that's what the admin interface does for filters... is there any difference? NEW SHELL SESSION FROM TODAY, TESTING SAME THING: >>> from dictionary.models import Entry >>> entries = Entry.objects.filter(active=False) >>> entries.count() 3642 >>> e1 = entries[0] >>> e1 >>> e1.active False -- 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+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Problem updating data
The main issue is that your queryset entries wasn't refreshed from the database. Do your queryset again and you'll see one fewer. Also, instead of zero you should use False when querying a boolean field. Shawn -- 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+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Problem updating data
I have a model "Entry" with an "active" field, which is just a boolean. All of the current entries were false, and I was trying to set them all as true, and I'm running into a strange problem. Here's an example, trying to set just one entry to inactive: >>> from dictionary.models import Entry >>> entries = Entry.objects.filter(active=0) >>> entries.count() 3642 >>> e1 = entries[0] >>> e1 >>> e1.active False >>> e1.active=True >>> e1.save() >>> e1.active True >>> Entry.objects.filter(active=0).count() 3642 Even though, when I checked e1.active, it showed it as being "True", you can tell from the final count of inactive items that it hadn't actually changed. I see the same thing when I go into the admin change page for that item -- "Active" is not checked. What is going on here? ~Karen -- 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+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.