List Info

Thread: IPython Shell does not see database changes made by views.




IPython Shell does not see database changes made by views.
user name
2007-01-31 09:48:27
During unit testing I made changes to data in the database
through my
Django app.

I wanted to do some checks through the shell, which I was
opened
during my unit testing, and found that after making some
queries using
Django objects there appeared to be no changes in the
database. When I
checked the database using its admin tool the changes were
there.

To yield the expected results I had to exit from the shell
and restart
it. I then executed my queries using Django objects and all
the
changes were there.

Does anyone know how to "refresh" or better yet
"auto refresh" the
shell so I don't have to shut down and restart it every time
I make a
change to data outside of it.

I'm using IPython 0.7.2 , MySQL 5.0.27, and a dev version of
Django
from a couple of weeks ago.

Thanks in advance,
/Paul


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


Re: IPython Shell does not see database changes made by views.
user name
2007-01-31 09:57:57
Paul Childs wrote:
> I wanted to do some checks through the shell, which I
was opened
> during my unit testing, and found that after making
some queries using
> Django objects there appeared to be no changes in the
database. When I
> checked the database using its admin tool the changes
were there.

This sounds like caching in querysets. When you do things
like this:

     objects = Model.objects.all()
     for obj in objects:
       print obj

The 'objects' once evaluated don't look into database again,
it keeps 
the result itself. To query database again just create a new
queryset 
from the Model's manager:

     objects = Model.objects.all()

I.e. each 'Model.objects.something...' will create a fresh
queryset that 
will query database again.

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


Re: IPython Shell does not see database changes made by views.
user name
2007-01-31 10:33:55
Ivan Sagalaev:
> Paul Childs wrote:
>> I wanted to do some checks through the shell, which
I was opened
>> during my unit testing, and found that after making
some queries using
>> Django objects there appeared to be no changes in
the database. When I
>> checked the database using its admin tool the
changes were there.
> 
> This sounds like caching in querysets.

If it's not that, then it might be that it's because you
have an
open transaction in the python shell, and you see only data
that had
been committed before the transaction started. You get
around it
with a commit in the shell. I think we had that on this
mailing list
before, so search a bit for more details.

Michael


-- 
noris network AG - Deutschherrnstraße 15-19 - D-90429
Nürnberg -
Tel +49-911-9352-0 - Fax +49-911-9352-100

http://www.noris.de - The
IT-Outsourcing Company

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


[1-3]

about | contact  Other archives ( Real Estate discussion Medical topics )