On Wed, Oct 7, 2009 at 7:39 PM, laligatz <lalig...@gmail.com> wrote:

>
> Hi everybody.
>
> I'm stuck on a problem with the Django ORM.
> After a basic query like select * from table where id = 1, the result
> is still the same although i've update the row in the DB.
>
> Example:
>
> >>> Tag.objects.all()
> [<Tag: tag1>]
>
> >>> tag = Tag.objects.all().get()
> >>> tag
> <Tag: tag1>
>
> >>>  tag.name = 'tag11'
> >>>  tag.save()
>
> >>>  Tag.objects.all()
> [<Tag: tag1>]
>
> How to say to Django to make the query again ?
>
>
I cannot recreate this.  With this model:

class Tag(models.Model):
   name = models.CharField(max_length=22)
   def __unicode__(self):
      return self.name

your sequence of commands produces:

>>> from ttt.models import Tag
>>> Tag.objects.all()
[]
>>> Tag.objects.create(name='tag1')
<Tag: tag1>
>>> Tag.objects.all()
[<Tag: tag1>]
>>> tag = Tag.objects.get()
>>> tag
<Tag: tag1>
>>> tag.name = 'tag11'
>>> tag.save()
>>> Tag.objects.all()
[<Tag: tag11>]

Is there something you've left out of your account that might be a clue?
What's this standalone script mentioned in the subject?  Despite looking
like your sequence is from a singe python shell session, is the update being
done by a different shell/script than the query?  If so, and if you are
using MySQL/InnoDB I suspect the problem is to do its default transaction
isolation level.  But at this point point I'm leaping pretty high to a
conclusion based on guesses about what you might be doing, not what you've
actually said you are doing.

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
-~----------~----~----~----~------~----~------~--~---

Reply via email to