I found, each request will call a new connection to mysql in django1.4 
while not in django1.5,
in django1.5, connections will be cached and reused by new requests. Thus, 
there be a problem,
the MySQLdb need a  explicit connection.commit() before or after every 
connection.execute() in order to
get the latest updated data from mysql (UPDATE or INSERT could be execute 
in another shell or connection).
And, the django1.5 does not do connection.commit() before any filter() by 
default.
Then, I think the next step is to find out if there is any option in 
django1.5 to do this commit()


在 2013年8月5日星期一UTC+8下午6时13分21秒,Zhouhf写道:
>
> recently I ran into a problem whitch doubt me a lot,
>
> I did some UPDATE in MySQL:  UPDATE tablename SET content="B"  where 
> content="A";
> and commit, exit shell of MySQL
> then **with no reload uwsgi**
> model.objects.filter() in views.py just got different result in 
> requests,like:
>     (request1)   http://.../request/:   --- got -->      {"id": 1, 
> "content": "A"}
>     (request2)   http://.../request/:   --- got -->      {"id": 1, 
> "content": "B"}
>     (request3)   http://.../request/:   --- got -->      {"id": 1, 
> "content": "A"}
>     (request4)   http://.../request/:   --- got -->      {"id": 1, 
> "content": "A"}
>     (request5)   http://.../request/:   --- got -->      {"id": 1, 
> "content": "A"}
>     (request6)   http://.../request/:   --- got -->      {"id": 1, 
> "content": "B"}
>    # this is wrong
>
>    **after reload uwsgi**
>     (request1)   http://.../request/:   --- got -->      {"id": 1, 
> "content": "B"}
>     (request2)   http://.../request/:   --- got -->      {"id": 1, 
> "content": "B"}
>     (request3)   http://.../request/:   --- got -->      {"id": 1, 
> "content": "B"}
>     (request4)   http://.../request/:   --- got -->      {"id": 1, 
> "content": "B"}
>     (request5)   http://.../request/:   --- got -->      {"id": 1, 
> "content": "B"}
>    # this is correct
>
> filter(parameters** ), parameters is all the same (unchanged),  but 
> diffrent return,
> then I test in django1.4.5,  no such problem,
> this happens in django1.5.0 and 1.5.1  and ...
>
>
> so I wonder if I did someting wrong or there is anything wrong with 
> django1.5,
> Anybody has the same problem? Or ,anyone can help? thanks!

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to