Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8443971
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T09:16:59+00:00 2026-06-10T09:16:59+00:00

I have django 1.3.1, python2.6 and MySQL 5.5.20. init_command in setting.py is set to

  • 0

I have django 1.3.1, python2.6 and MySQL 5.5.20.
init_command in setting.py is set to SET storage_engine=INNODB.

I have the following situation:

Consider the model:

class Fruit(models.Model):
    name = models.CharField(max_length=50)

    def __unicode__(self):
        return self.name

Now I open two Django shells and type:

django shell I:

./manage.py shell
(InteractiveConsole)
>>> import fruits.models as m
>>> m.Fruit(name="apple").save()
>>> m.Fruit.objects.get(pk=1)    
<Fruit: apple>

django shell II:

./manage.py shell
(InteractiveConsole)
>>> import fruits.models as m
>>> m.Fruit.objects.get(pk=1)    
<Fruit: apple>

So far so good. Now I continue to type in shell I:

>>> m.Fruit(name="peach").save()
>>> m.Fruit.objects.get(pk=2)
<Fruit: peach>

Qestion: Why typing the following in the shell II does not find the object?

>>> m.Fruit.objects.get(pk=2)
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "..../django/db/models/manager.py", line 132, in get
    return self.get_query_set().get(*args, **kwargs)
  File "..../django/db/models/query.py", line 349, in get
    % self.model._meta.object_name)
DoesNotExist: Fruit matching query does not exist.

The only way I’ve found to make shell II to have “a fresh look” is this:

>>> from django.db import transaction
>>> transaction.enter_transaction_management()
>>> transaction.rollback()

And I need to roolback() each time I query for fruits if I want to be sure that orm will not “lie”.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T09:17:01+00:00Added an answer on June 10, 2026 at 9:17 am

    This is a issolation issue. You can relax to ‘isolation level read commited’ to avoid this behavior. Also, learn about this issolation level implications (phantoms).

    To set Read Commited Isolation Level into MySQL for your django project you should set this parameter in settings.py:

    DATABASE_OPTIONS = { 
         "init_command": 'SET storage_engine=INNODB,    \
                          SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED', }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using django with mysql (InnoDB) and have the following in my django
I have the following code: settings.py DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME':
I have a Django model with a decimal field: class User(models.Model): ... balance =
I have Python2.7 and Django 1.3.1, running on windows 7 32bit When I type
Imagine you have a web application written in Django and Python 2.65, and MySQL
I have a MySQL database called People which contains the following schema <id,name,foodchoice1,foodchoice2> .
I am developing a web application using Python, Django and MySql. I have a
I have the following stack trace when trying to access the django admin default
I have developed a project with Django framework(python and mysql DB) in Linux OS(Ubuntu
I'm using django-tables (http://pypi.python.org/pypi/django-tables/0.2) to render the contents of a MySQL table. The model

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.