Good morning, everyone!
Apologies in advance if this is the wrong place to ask this question.

First of all, the setup. I'm using MySQL and InnoDB tables.

I've encountered an unusual problem, which has reared its ugly head on
several fronts. The basic jist is that Django seems to not recognize
database changes made...I think since the beginning of the request.
It's caused some interesting issues, like getting an IntegrityError on
a get_or_create call (which one would think would not be possible).

The most succinct reproduction case I can give would be this. Assume a
model "Source" (and corresponding table in MySQL). It has an empty
table. I will start a shell, try to pull the source with the id of 1.
It will raise DoesNotExist (correctly). I will then go add one, with
an id of 1. I now expect the same request to work, but in fact it does
not.

$ ./manage.py shell
>>> from mysite.myapp.models import Source
>>> s = Source.objects.get(id = 1)
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/usr/local/share/django/django/db/models/manager.py", line
120, in get
    return self.get_query_set().get(*args, **kwargs)
  File "/usr/local/share/django/django/db/models/query.py", line 305,
in get
    % self.model._meta.object_name)
DoesNotExist: Source matching query does not exist.
>>>
>>> # added a database entry here, and confirmed its primary key (id) was 1
>>>
>>> s = Source.objects.get(id = 1)
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/usr/local/share/django/django/db/models/manager.py", line
120, in get
    return self.get_query_set().get(*args, **kwargs)
  File "/usr/local/share/django/django/db/models/query.py", line 305,
in get
    % self.model._meta.object_name)
DoesNotExist: Source matching query does not exist.

What am I doing wrong?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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