Opened 14 years ago
Closed 10 years ago
#14932 closed Uncategorized (fixed)
Tests failing with SQLite3 on Linux systems; Sites object causing failures.
Reported by: | Owned by: | nobody | |
---|---|---|---|
Component: | Uncategorized | Version: | 1.2 |
Severity: | Normal | Keywords: | sqlite3 app-loading |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Running Django 1.2.3 on Ubuntu 10.04. Originally using SQLite 3.6.2, which there is known bugs for so I upgraded to 3.7.2 and am still having issues.
This was happening on OSX, then I wrapped the current_site code into functions or init statements. However, it still seems to happen on any that may be somehow reached by module loading. This does not happen anymore on OSX, and does not happen with mySQL
Here's a traceback:
Traceback (most recent call last): File "company/manage.py", line 12, in <module> execute_manager(settings) File "/home/alfred/.hudson/jobs/company-sqlite/workspace/ve/lib/python2.6/site-packages/django/core/management/__init__.py", line 438, in execute_manager utility.execute() File "/home/alfred/.hudson/jobs/company-sqlite/workspace/ve/lib/python2.6/site-packages/django/core/management/__init__.py", line 379, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/home/alfred/.hudson/jobs/company-sqlite/workspace/ve/lib/python2.6/site-packages/django/core/management/base.py", line 191, in run_from_argv self.execute(*args, **options.__dict__) File "/home/alfred/.hudson/jobs/company-sqlite/workspace/ve/lib/python2.6/site-packages/django/core/management/base.py", line 219, in execute self.validate() File "/home/alfred/.hudson/jobs/company-sqlite/workspace/ve/lib/python2.6/site-packages/django/core/management/base.py", line 249, in validate num_errors = get_validation_errors(s, app) File "/home/alfred/.hudson/jobs/company-sqlite/workspace/ve/lib/python2.6/site-packages/django/core/management/validation.py", line 28, in get_validation_errors for (app_name, error) in get_app_errors().items(): File "/home/alfred/.hudson/jobs/company-sqlite/workspace/ve/lib/python2.6/site-packages/django/db/models/loading.py", line 146, in get_app_errors self._populate() File "/home/alfred/.hudson/jobs/company-sqlite/workspace/ve/lib/python2.6/site-packages/django/db/models/loading.py", line 61, in _populate self.load_app(app_name, True) File "/home/alfred/.hudson/jobs/company-sqlite/workspace/ve/lib/python2.6/site-packages/django/db/models/loading.py", line 78, in load_app models = import_module('.models', app_name) File "/home/alfred/.hudson/jobs/company-sqlite/workspace/ve/lib/python2.6/site-packages/django/utils/importlib.py", line 35, in import_module __import__(name) File "/home/alfred/.hudson/jobs/company-sqlite/workspace/company/associates/yyz/models.py", line 258, in <module> get_current_site() File "/home/alfred/.hudson/jobs/company-sqlite/workspace/company/associates/yyz/models.py", line 254, in get_current_site current_site = Site.objects.get_current() File "/home/alfred/.hudson/jobs/company-sqlite/workspace/ve/lib/python2.6/site-packages/django/contrib/sites/models.py", line 22, in get_current current_site = self.get(pk=sid) File "/home/alfred/.hudson/jobs/company-sqlite/workspace/ve/lib/python2.6/site-packages/django/db/models/manager.py", line 132, in get return self.get_query_set().get(*args, **kwargs) File "/home/alfred/.hudson/jobs/company-sqlite/workspace/ve/lib/python2.6/site-packages/django/db/models/query.py", line 333, in get clone = self.filter(*args, **kwargs) File "/home/alfred/.hudson/jobs/company-sqlite/workspace/ve/lib/python2.6/site-packages/django/db/models/query.py", line 550, in filter return self._filter_or_exclude(False, *args, **kwargs) File "/home/alfred/.hudson/jobs/company-sqlite/workspace/ve/lib/python2.6/site-packages/django/db/models/query.py", line 568, in _filter_or_exclude clone.query.add_q(Q(*args, **kwargs)) me/alfred/.hudson/jobs/company-sqlite/workspace/ve/lib/python2.6/site-packages/django/db/models/sql/query.py", line 1128, in add_q can_reuse=used_aliases) File "/home/alfred/.hudson/jobs/company-sqlite/workspace/ve/lib/python2.6/site-packages/django/db/models/sql/query.py", line 1026, in add_filter negate=negate, process_extras=process_extras) File "/home/alfred/.hudson/jobs/company-sqlite/workspace/ve/lib/python2.6/site-packages/django/db/models/sql/query.py", line 1179, in setup_joins field, model, direct, m2m = opts.get_field_by_name(name) File "/home/alfred/.hudson/jobs/company-sqlite/workspace/ve/lib/python2.6/site-packages/django/db/models/options.py", line 291, in get_field_by_name cache = self.init_name_map() File "/home/alfred/.hudson/jobs/company-sqlite/workspace/ve/lib/python2.6/site-packages/django/db/models/options.py", line 321, in init_name_map for f, model in self.get_all_related_m2m_objects_with_model(): File "/home/alfred/.hudson/jobs/company-sqlite/workspace/ve/lib/python2.6/site-packages/django/db/models/options.py", line 396, in get_all_related_m2m_objects_with_model cache = self._fill_related_many_to_many_cache() File "/home/alfred/.hudson/jobs/company-sqlite/workspace/ve/lib/python2.6/site-packages/django/db/models/options.py", line 410, in _fill_related_many_to_many_cache for klass in get_models(): File "/home/alfred/.hudson/jobs/company-sqlite/workspace/ve/lib/python2.6/site-packages/django/db/models/loading.py", line 167, in get_models self._populate() File "/home/alfred/.hudson/jobs/company-sqlite/workspace/ve/lib/python2.6/site-packages/django/db/models/loading.py", line 61, in _populate self.load_app(app_name, True) File "/home/alfred/.hudson/jobs/company-sqlite/workspace/ve/lib/python2.6/site-packages/django/db/models/loading.py", line 78, in load_app models = import_module('.models', app_name) File "/home/alfred/.hudson/jobs/company-sqlite/workspace/ve/lib/python2.6/site-packages/django/utils/importlib.py", line 35, in import_module __import__(name) File "/home/alfred/.hudson/jobs/company-sqlite/workspace/company/evaluations/models.py", line 33, in <module> LABELS = Labels() File "/home/alfred/.hudson/jobs/company-sqlite/workspace/company/evaluations/labels.py", line 28, in __init__ current_site = Site.objects.get_current() File "/home/alfred/.hudson/jobs/company-sqlite/workspace/ve/lib/python2.6/site-packages/django/contrib/sites/models.py", line 22, in get_current current_site = self.get(pk=sid) File "/home/alfred/.hudson/jobs/company-sqlite/workspace/ve/lib/python2.6/site-packages/django/db/models/manager.py", line 132, in get return self.get_query_set().get(*args, **kwargs) File "/home/alfred/.hudson/jobs/company-sqlite/workspace/ve/lib/python2.6/site-packages/django/db/models/query.py", line 333, in get clone = self.filter(*args, **kwargs) File "/home/alfred/.hudson/jobs/company-sqlite/workspace/ve/lib/python2.6/site-packages/django/db/models/query.py", line 550, in filter return self._filter_or_exclude(False, *args, **kwargs) File "/home/alfred/.hudson/jobs/company-sqlite/workspace/ve/lib/python2.6/site-packages/django/db/models/query.py", line 568, in _filter_or_exclude clone.query.add_q(Q(*args, **kwargs)) File "/home/alfred/.hudson/jobs/company-sqlite/workspace/ve/lib/python2.6/site-packages/django/db/models/sql/query.py", line 1128, in add_q can_reuse=used_aliases) File "/home/alfred/.hudson/jobs/company-sqlite/workspace/ve/lib/python2.6/site-packages/django/db/models/sql/query.py", line 1026, in add_filter negate=negate, process_extras=process_extras) File "/home/alfred/.hudson/jobs/company-sqlite/workspace/ve/lib/python2.6/site-packages/django/db/models/sql/query.py", line 1179, in setup_joins field, model, direct, m2m = opts.get_field_by_name(name) File "/home/alfred/.hudson/jobs/company-sqlite/workspace/ve/lib/python2.6/site-packages/django/db/models/options.py", line 291, in get_field_by_name cache = self.init_name_map() File "/home/alfred/.hudson/jobs/company-sqlite/workspace/ve/lib/python2.6/site-packages/django/db/models/options.py", line 321, in init_name_map for f, model in self.get_all_related_m2m_objects_with_model(): File "/home/alfred/.hudson/jobs/company-sqlite/workspace/ve/lib/python2.6/site-packages/django/db/models/options.py", line 396, in get_all_related_m2m_objects_with_model cache = self._fill_related_many_to_many_cache()
And it goes through the files that call Site.objects.get_current_site() in the module loading, and finally ends with:
File "/home/alfred/.hudson/jobs/company-sqlite/workspace/ve/lib/python2.6/site-packages/django/db/models/sql/compiler.py", line 727, in execute_sql cursor.execute(sql, params) File "/home/alfred/.hudson/jobs/company-sqlite/workspace/ve/lib/python2.6/site-packages/django/db/backends/util.py", line 15, in execute return self.cursor.execute(sql, params) File "/home/alfred/.hudson/jobs/company-sqlite/workspace/ve/lib/python2.6/site-packages/django/db/backends/sqlite3/base.py", line 200, in execute return Database.Cursor.execute(self, query, params) django.db.utils.DatabaseError: no such table: django_site
At this point, I'm out of ideas and can only think this is some obscure bug.
Change History (4)
comment:1 by , 14 years ago
Resolution: | → worksforme |
---|---|
Status: | new → closed |
comment:3 by , 10 years ago
Easy pickings: | unset |
---|---|
Resolution: | worksforme |
Severity: | → Normal |
Status: | closed → new |
Type: | → Uncategorized |
UI/UX: | unset |
Just happened to me - reproducing:
use a model import in ini of an app
from configuration.models import myModel
run the testing suite with sqlite db
get:
django.db.utils.OperationalError: no such table: configuration_myModel
comment:4 by , 10 years ago
Keywords: | app-loading added |
---|---|
Resolution: | → fixed |
Status: | new → closed |
It isn't clear which conditions triggered this bug, but it cannot happen anymore in Django 1.7+, thanks to the app-loading refactor. Now it's explicitly forbidden to import models in __init__.py
at the root of an application.
I don't know where to start to reproduce this.
Are you running the Django test suite? If so in which test does this happen? (you've not included the header of the output that appears above the traceback) or tests for your application?. What is the settings file you are using (of particular interest is the DATABASES setting.)
I'm using Debian Sid (sqlite 3.7.4) and don't see this error when running the Django suite for both trunk and the 1.2.X as of now using the
tests/test_sqlite.py
setting file.I'm going to close this ticket, please reopen it if you still can reproduce it, and please include some of the details described above.