Django multisite: ValueError: SITE_ID has not been set - python

I recently got a new computer and have been trying to set my development environment back up, which right now I need to develop a Django project. However, I keep running into this following error whenever I try to do python manage.py runserver, makemigrations, migrate, etc and I don't understand why.
Traceback (most recent call last):
File "manage.py", line 17, in <module>
execute_from_command_line(sys.argv)
File "/usr/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 338, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 312, in execute
django.setup()
File "/usr/local/lib/python2.7/site-packages/django/__init__.py", line 18, in setup
apps.populate(settings.INSTALLED_APPS)
File "/usr/local/lib/python2.7/site-packages/django/apps/registry.py", line 115, in populate
app_config.ready()
File "/usr/local/lib/python2.7/site-packages/debug_toolbar/apps.py", line 15, in ready
dt_settings.patch_all()
File "/usr/local/lib/python2.7/site-packages/debug_toolbar/settings.py", line 232, in patch_all
patch_root_urlconf()
File "/usr/local/lib/python2.7/site-packages/debug_toolbar/settings.py", line 220, in patch_root_urlconf
reverse('djdt:render_panel')
File "/usr/local/lib/python2.7/site-packages/django/core/urlresolvers.py", line 550, in reverse
app_list = resolver.app_dict[ns]
File "/usr/local/lib/python2.7/site-packages/django/core/urlresolvers.py", line 352, in app_dict
self._populate()
File "/usr/local/lib/python2.7/site-packages/django/core/urlresolvers.py", line 285, in _populate
for pattern in reversed(self.url_patterns):
File "/usr/local/lib/python2.7/site-packages/django/core/urlresolvers.py", line 402, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "/usr/local/lib/python2.7/site-packages/django/core/urlresolvers.py", line 396, in urlconf_module
self._urlconf_module = import_module(self.urlconf_name)
File "/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/Users/Lily/Sites/StartupTree/StartupTree/urls.py", line 48, in <module>
+ static(settings.STATIC_URL, document_root=settings.STATICFILES_DIRS[0])
File "/usr/local/lib/python2.7/site-packages/django/conf/urls/__init__.py", line 33, in include
urlconf_module = import_module(urlconf_module)
File "/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/Users/Lily/Sites/StartupTree/branch/urls.py", line 2, in <module>
from branch.views import (
File "/Users/Lily/Sites/StartupTree/branch/views/__init__.py", line 15, in <module>
from app.views import home as home_redirect
File "/Users/Lily/Sites/StartupTree/app/views.py", line 5, in <module>
from emailuser.views import user_login as login_redirect
File "/Users/Lily/Sites/StartupTree/emailuser/views/__init__.py", line 32, in <module>
from branch.modelforms import (
File "/Users/Lily/Sites/StartupTree/branch/modelforms.py", line 139, in <module>
class ExperienceForm(forms.ModelForm):
File "/usr/local/lib/python2.7/site-packages/django/forms/models.py", line 285, in __new__
opts.help_texts, opts.error_messages)
File "/usr/local/lib/python2.7/site-packages/django/forms/models.py", line 212, in fields_for_model
formfield = f.formfield(**kwargs)
File "/usr/local/lib/python2.7/site-packages/django/db/models/fields/related.py", line 1981, in formfield
'queryset': self.rel.to._default_manager.using(db),
File "/usr/local/lib/python2.7/site-packages/django/db/models/manager.py", line 127, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "/usr/local/lib/python2.7/site-packages/django/contrib/sites/managers.py", line 66, in get_queryset
**{self._get_field_name() + '__id': settings.SITE_ID})
File "/usr/local/lib/python2.7/site-packages/django/db/models/query.py", line 679, in filter
return self._filter_or_exclude(False, *args, **kwargs)
File "/usr/local/lib/python2.7/site-packages/django/db/models/query.py", line 697, in _filter_or_exclude
clone.query.add_q(Q(*args, **kwargs))
File "/usr/local/lib/python2.7/site-packages/django/db/models/sql/query.py", line 1309, in add_q
clause, require_inner = self._add_q(where_part, self.used_aliases)
File "/usr/local/lib/python2.7/site-packages/django/db/models/sql/query.py", line 1337, in _add_q
allow_joins=allow_joins, split_subq=split_subq,
File "/usr/local/lib/python2.7/site-packages/django/db/models/sql/query.py", line 1208, in build_filter
condition = self.build_lookup(lookups, col, value)
File "/usr/local/lib/python2.7/site-packages/django/db/models/sql/query.py", line 1101, in build_lookup
return final_lookup(lhs, rhs)
File "/usr/local/lib/python2.7/site-packages/django/db/models/lookups.py", line 101, in __init__
self.rhs = self.get_prep_lookup()
File "/usr/local/lib/python2.7/site-packages/django/db/models/lookups.py", line 139, in get_prep_lookup
return self.lhs.output_field.get_prep_lookup(self.lookup_name, self.rhs)
File "/usr/local/lib/python2.7/site-packages/django/db/models/fields/__init__.py", line 727, in get_prep_lookup
return self.get_prep_value(value)
File "/usr/local/lib/python2.7/site-packages/django/db/models/fields/__init__.py", line 985, in get_prep_value
return int(value)
File "/usr/local/lib/python2.7/site-packages/multisite/threadlocals.py", line 57, in __int__
return self.get_default()
File "/usr/local/lib/python2.7/site-packages/multisite/threadlocals.py", line 119, in get_default
raise ValueError('SITE_ID has not been set.')
ValueError: SITE_ID has not been set.
I've checked my settings.py and found SITE_ID = 1 so I'm assuming that's what it wants? (I'm also very new to Django, sorry!)
Thanks so much in advance for your help!

When using django-multisite you need to set up the SITE_ID as follows
from multisite import SiteID
SITE_ID = SiteID()

From command line intro your enviroment:
$ export SITE_ID = 1

Related

django.db.utils.OperationalError: no such table: bookmarks_mytag

I am getting django.db.utils.OperationalError: no such table: bookmarks_mytag trying to install a django project.
The repo is at http://bitbucket.org/codyc54321/bookwormbud.git
We did
touch db.sqlite3
python manage.py migrate
and it blows up:
(bookwormbuddy) john#john-Precision-3510:~/Documents/cody_work/codyc54321-bookwormbud-f7f43c3908ca$ python manage.py runserver
Performing system checks...
Unhandled exception in thread started by <function wrapper at 0x7f7adbb5e140>
Traceback (most recent call last):
File "/home/john/anaconda3/envs/bookwormbuddy/lib/python2.7/site-packages/django/utils/autoreload.py", line 227, in wrapper
fn(*args, **kwargs)
File "/home/john/anaconda3/envs/bookwormbuddy/lib/python2.7/site-packages/django/core/management/commands/runserver.py", line 125, in inner_run
self.check(display_num_errors=True)
File "/home/john/anaconda3/envs/bookwormbuddy/lib/python2.7/site-packages/django/core/management/base.py", line 359, in check
include_deployment_checks=include_deployment_checks,
File "/home/john/anaconda3/envs/bookwormbuddy/lib/python2.7/site-packages/django/core/management/base.py", line 346, in _run_checks
return checks.run_checks(**kwargs)
File "/home/john/anaconda3/envs/bookwormbuddy/lib/python2.7/site-packages/django/core/checks/registry.py", line 81, in run_checks
new_errors = check(app_configs=app_configs)
File "/home/john/anaconda3/envs/bookwormbuddy/lib/python2.7/site-packages/django/core/checks/urls.py", line 16, in check_url_config
return check_resolver(resolver)
File "/home/john/anaconda3/envs/bookwormbuddy/lib/python2.7/site-packages/django/core/checks/urls.py", line 26, in check_resolver
return check_method()
File "/home/john/anaconda3/envs/bookwormbuddy/lib/python2.7/site-packages/django/urls/resolvers.py", line 254, in check
for pattern in self.url_patterns:
File "/home/john/anaconda3/envs/bookwormbuddy/lib/python2.7/site-packages/django/utils/functional.py", line 35, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/home/john/anaconda3/envs/bookwormbuddy/lib/python2.7/site-packages/django/urls/resolvers.py", line 405, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "/home/john/anaconda3/envs/bookwormbuddy/lib/python2.7/site-packages/django/utils/functional.py", line 35, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/home/john/anaconda3/envs/bookwormbuddy/lib/python2.7/site-packages/django/urls/resolvers.py", line 398, in urlconf_module
return import_module(self.urlconf_name)
File "/home/john/anaconda3/envs/bookwormbuddy/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/home/john/Documents/cody_work/codyc54321-bookwormbud-f7f43c3908ca/bookwormbud/urls.py", line 24, in <module>
url(r'^', include('bookmarks.urls', namespace='bookmarks')),
File "/home/john/anaconda3/envs/bookwormbuddy/lib/python2.7/site-packages/django/conf/urls/__init__.py", line 50, in include
urlconf_module = import_module(urlconf_module)
File "/home/john/anaconda3/envs/bookwormbuddy/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/home/john/Documents/cody_work/codyc54321-bookwormbud-f7f43c3908ca/bookmarks/urls.py", line 4, in <module>
from bookmarks import views
File "/home/john/Documents/cody_work/codyc54321-bookwormbud-f7f43c3908ca/bookmarks/views.py", line 24, in <module>
from bookmarks.forms import ArticleForm, TagForm, TagSelectForm, EditArticleForm, AddedDateCalendarForm, LastViewedDateCalendarForm
File "/home/john/Documents/cody_work/codyc54321-bookwormbud-f7f43c3908ca/bookmarks/forms.py", line 120, in <module>
class TagSelectForm(forms.ModelForm):
File "/home/john/Documents/cody_work/codyc54321-bookwormbud-f7f43c3908ca/bookmarks/forms.py", line 127, in TagSelectForm
choices=get_tag_choices()
File "/home/john/Documents/cody_work/codyc54321-bookwormbud-f7f43c3908ca/bookmarks/forms.py", line 112, in get_tag_choices
if tags:
File "/home/john/anaconda3/envs/bookwormbuddy/lib/python2.7/site-packages/django/db/models/query.py", line 258, in __nonzero__
return type(self).__bool__(self)
File "/home/john/anaconda3/envs/bookwormbuddy/lib/python2.7/site-packages/django/db/models/query.py", line 254, in __bool__
self._fetch_all()
File "/home/john/anaconda3/envs/bookwormbuddy/lib/python2.7/site-packages/django/db/models/query.py", line 1118, in _fetch_all
self._result_cache = list(self._iterable_class(self))
File "/home/john/anaconda3/envs/bookwormbuddy/lib/python2.7/site-packages/django/db/models/query.py", line 53, in __iter__
results = compiler.execute_sql(chunked_fetch=self.chunked_fetch)
File "/home/john/anaconda3/envs/bookwormbuddy/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 886, in execute_sql
raise original_exception
django.db.utils.OperationalError: no such table: bookmarks_mytag
^C(bookwormbuddy) john#john-Precision-3510:~/Documents/cody_work/codyc54321-bookwormbud-f7f43c3908ca$ touch db.sqlite3
(bookwormbuddy) john#john-Precision-3510:~/Documents/cody_work/codyc54321-bookwormbud-f7f43c3908ca$ python manage.py migrate
Traceback (most recent call last):
File "manage.py", line 22, in <module>
execute_from_command_line(sys.argv)
File "/home/john/anaconda3/envs/bookwormbuddy/lib/python2.7/site-packages/django/core/management/__init__.py", line 363, in execute_from_command_line
utility.execute()
File "/home/john/anaconda3/envs/bookwormbuddy/lib/python2.7/site-packages/django/core/management/__init__.py", line 355, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/john/anaconda3/envs/bookwormbuddy/lib/python2.7/site-packages/django/core/management/base.py", line 283, in run_from_argv
self.execute(*args, **cmd_options)
File "/home/john/anaconda3/envs/bookwormbuddy/lib/python2.7/site-packages/django/core/management/base.py", line 327, in execute
self.check()
File "/home/john/anaconda3/envs/bookwormbuddy/lib/python2.7/site-packages/django/core/management/base.py", line 359, in check
include_deployment_checks=include_deployment_checks,
File "/home/john/anaconda3/envs/bookwormbuddy/lib/python2.7/site-packages/django/core/management/commands/migrate.py", line 62, in _run_checks
issues.extend(super(Command, self)._run_checks(**kwargs))
File "/home/john/anaconda3/envs/bookwormbuddy/lib/python2.7/site-packages/django/core/management/base.py", line 346, in _run_checks
return checks.run_checks(**kwargs)
File "/home/john/anaconda3/envs/bookwormbuddy/lib/python2.7/site-packages/django/core/checks/registry.py", line 81, in run_checks
new_errors = check(app_configs=app_configs)
File "/home/john/anaconda3/envs/bookwormbuddy/lib/python2.7/site-packages/django/core/checks/urls.py", line 16, in check_url_config
return check_resolver(resolver)
File "/home/john/anaconda3/envs/bookwormbuddy/lib/python2.7/site-packages/django/core/checks/urls.py", line 26, in check_resolver
return check_method()
File "/home/john/anaconda3/envs/bookwormbuddy/lib/python2.7/site-packages/django/urls/resolvers.py", line 254, in check
for pattern in self.url_patterns:
File "/home/john/anaconda3/envs/bookwormbuddy/lib/python2.7/site-packages/django/utils/functional.py", line 35, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/home/john/anaconda3/envs/bookwormbuddy/lib/python2.7/site-packages/django/urls/resolvers.py", line 405, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "/home/john/anaconda3/envs/bookwormbuddy/lib/python2.7/site-packages/django/utils/functional.py", line 35, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/home/john/anaconda3/envs/bookwormbuddy/lib/python2.7/site-packages/django/urls/resolvers.py", line 398, in urlconf_module
return import_module(self.urlconf_name)
File "/home/john/anaconda3/envs/bookwormbuddy/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/home/john/Documents/cody_work/codyc54321-bookwormbud-f7f43c3908ca/bookwormbud/urls.py", line 24, in <module>
url(r'^', include('bookmarks.urls', namespace='bookmarks')),
File "/home/john/anaconda3/envs/bookwormbuddy/lib/python2.7/site-packages/django/conf/urls/__init__.py", line 50, in include
urlconf_module = import_module(urlconf_module)
File "/home/john/anaconda3/envs/bookwormbuddy/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/home/john/Documents/cody_work/codyc54321-bookwormbud-f7f43c3908ca/bookmarks/urls.py", line 4, in <module>
from bookmarks import views
File "/home/john/Documents/cody_work/codyc54321-bookwormbud-f7f43c3908ca/bookmarks/views.py", line 24, in <module>
from bookmarks.forms import ArticleForm, TagForm, TagSelectForm, EditArticleForm, AddedDateCalendarForm, LastViewedDateCalendarForm
File "/home/john/Documents/cody_work/codyc54321-bookwormbud-f7f43c3908ca/bookmarks/forms.py", line 120, in <module>
class TagSelectForm(forms.ModelForm):
File "/home/john/Documents/cody_work/codyc54321-bookwormbud-f7f43c3908ca/bookmarks/forms.py", line 127, in TagSelectForm
choices=get_tag_choices()
File "/home/john/Documents/cody_work/codyc54321-bookwormbud-f7f43c3908ca/bookmarks/forms.py", line 112, in get_tag_choices
if tags:
File "/home/john/anaconda3/envs/bookwormbuddy/lib/python2.7/site-packages/django/db/models/query.py", line 258, in __nonzero__
return type(self).__bool__(self)
File "/home/john/anaconda3/envs/bookwormbuddy/lib/python2.7/site-packages/django/db/models/query.py", line 254, in __bool__
self._fetch_all()
File "/home/john/anaconda3/envs/bookwormbuddy/lib/python2.7/site-packages/django/db/models/query.py", line 1118, in _fetch_all
self._result_cache = list(self._iterable_class(self))
File "/home/john/anaconda3/envs/bookwormbuddy/lib/python2.7/site-packages/django/db/models/query.py", line 53, in __iter__
results = compiler.execute_sql(chunked_fetch=self.chunked_fetch)
File "/home/john/anaconda3/envs/bookwormbuddy/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 886, in execute_sql
raise original_exception
django.db.utils.OperationalError: no such table: bookmarks_mytag
The project installs immediately on a different laptop, but I don't remember how it was set up. The sqlite db has been deleted and remade empty as it was said to do on SO. Any help appreciated, thank you
You are creating an empty db file manually. You dont need to create that file manually. Delete your "db.sqlite3" file, then run command,
python manage.py makemigrations
If above command says "No changes detected", then run this command,
python manage.py makemigrations app_name
where, app_name will be your directory name in which models.py file is located,
using above command, you have successfully created migration files,
Now, simpy run,
python manage.py migrate
I hope this help
Did you try running python manage.py makemigrations before migrate?

Django: detect module level db queries

Database queries at modul level (aka import-time) can make trouble in django.
See: https://groups.google.com/forum/#!topic/django-developers/7JwWatLfP44/discussion
Trouble:
The real db gets accessed in tests, not the test-database.
Monkey patching in app-ready signals are too late
...
How can I detect the particular python source line which accesses my database before the app ready signal happens?
I found a solution. It's "dirty", but works.
If you add assert 0 to get_new_connection of django/db/backends/postgresql/base.py
Then you see a very long traceback. It reveals where you do access the database too early.
Of course you should only do this in your development environment.
I guess roughly the same should work for sqlite.
foobar_vums_d#aptguettler:~$ py.test -k ...
Traceback (most recent call last):
File "/home/foobar_vums_d/bin/py.test", line 11, in <module>
sys.exit(main())
File "/home/foobar_vums_d/local/lib/python2.7/site-packages/_pytest/config.py", line 49, in main
return config.hook.pytest_cmdline_main(config=config)
File "/home/foobar_vums_d/local/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py", line 724, in __call__
return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
File "/home/foobar_vums_d/local/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py", line 338, in _hookexec
return self._inner_hookexec(hook, methods, kwargs)
File "/home/foobar_vums_d/local/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py", line 333, in <lambda>
_MultiCall(methods, kwargs, hook.spec_opts).execute()
File "/home/foobar_vums_d/local/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py", line 596, in execute
res = hook_impl.function(*args)
File "/home/foobar_vums_d/local/lib/python2.7/site-packages/pytest_djangotools/hooks.py", line 46, in pytest_cmdline_main
import consolescript_django
File "/home/foobar_vums_d/src/djangotools/consolescript_django/__init__.py", line 11, in <module>
django.setup()
File "/home/foobar_vums_d/local/lib/python2.7/site-packages/django/__init__.py", line 18, in setup
apps.populate(settings.INSTALLED_APPS)
File "/home/foobar_vums_d/local/lib/python2.7/site-packages/django/apps/registry.py", line 115, in populate
app_config.ready()
File "/home/foobar_vums_d/src/djangotools/djangotools/apps.py", line 19, in ready
url_patterns = get_resolver(None).url_patterns
File "/home/foobar_vums_d/local/lib/python2.7/site-packages/django/utils/functional.py", line 33, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/home/foobar_vums_d/local/lib/python2.7/site-packages/django/core/urlresolvers.py", line 417, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "/home/foobar_vums_d/local/lib/python2.7/site-packages/django/utils/functional.py", line 33, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/home/foobar_vums_d/local/lib/python2.7/site-packages/django/core/urlresolvers.py", line 410, in urlconf_module
return import_module(self.urlconf_name)
File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/home/foobar_vums_d/src/foobar-vums/foobar_vums/etc/rooturls.py", line 11, in <module>
urlpatterns = collect_urlpatterns_from_apps()
File "/home/foobar_vums_d/src/djangotools/djangotools/utils/urlresolverutils.py", line 124, in collect_urlpatterns_from_apps
urls_module = importlib.import_module(app_import_string + '.urls')
File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/home/foobar_vums_d/src/foobar/foobar/urls.py", line 310, in <module>
urlpatterns.append(url(r'^', include(collect_urlpatterns_from_package(views))))
File "/home/foobar_vums_d/src/djangotools/djangotools/utils/urlresolverutils.py", line 94, in collect_urlpatterns_from_package
import_package(views_package)
File "/home/foobar_vums_d/src/djangotools/djangotools/utils/urlresolverutils.py", line 89, in import_package
importlib.import_module(module_name)
File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/home/foobar_vums_d/src/foobar/foobar/views/issue/legacy_edit2.py", line 55, in <module>
for index in Index.objects.all():
File "/home/foobar_vums_d/local/lib/python2.7/site-packages/django/db/models/query.py", line 258, in __iter__
self._fetch_all()
File "/home/foobar_vums_d/local/lib/python2.7/site-packages/django/db/models/query.py", line 1074, in _fetch_all
self._result_cache = list(self.iterator())
File "/home/foobar_vums_d/local/lib/python2.7/site-packages/django/db/models/query.py", line 52, in __iter__
results = compiler.execute_sql()
File "/home/foobar_vums_d/local/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 846, in execute_sql
cursor = self.connection.cursor()
File "/home/foobar_vums_d/local/lib/python2.7/site-packages/django/db/backends/base/base.py", line 231, in cursor
cursor = self.make_debug_cursor(self._cursor())
File "/home/foobar_vums_d/local/lib/python2.7/site-packages/django/db/backends/base/base.py", line 204, in _cursor
self.ensure_connection()
File "/home/foobar_vums_d/local/lib/python2.7/site-packages/django/db/backends/base/base.py", line 199, in ensure_connection
self.connect()
File "/home/foobar_vums_d/local/lib/python2.7/site-packages/django/db/backends/base/base.py", line 171, in connect
self.connection = self.get_new_connection(conn_params)
File "/home/foobar_vums_d/local/lib/python2.7/site-packages/django/db/backends/postgresql/base.py", line 175, in get_new_connection
connection = Database.connect(**conn_params)
File "/usr/lib/python2.7/dist-packages/psycopg2/__init__.py", line 105, in connect
assert 0
AssertionError
In this case the buggy line is in src/foobar/foobar/views/issue/legacy_edit2.py
You find this by going the stack from bottom to top, skipping all lines containing /site-packages/django/.

Django manage.py runserver got AppRegistryNotReady: Models aren't loaded yet

I hit a problem when run django from command line with manage.py runserver.
The same code is fine with Django 1.5 several months ago.
Today I wanna pickup the code again and run upon Django 1.8.3 and python2.7.10 .
Now, got error here:
Traceback (most recent call last):
File "manage.py", line 29, in <module>
execute_from_command_line(sys.argv)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 338, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 312, in execute
django.setup()
File "/usr/local/lib/python2.7/dist-packages/django/__init__.py", line 18, in setup
apps.populate(settings.INSTALLED_APPS)
File "/usr/local/lib/python2.7/dist-packages/django/apps/registry.py", line 108, in populate
app_config.import_models(all_models)
File "/usr/local/lib/python2.7/dist-packages/django/apps/config.py", line 198, in import_models
self.models_module = import_module(models_module_name)
File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/media/wni/study/workspace4320151111/weichun/mytheme/models.py", line 8, in <module>
from mezzanine.pages.models import Page
File "/media/wni/study/workspace4320151111/weichun/mezzanine/pages/models.py", line 34, in <module>
class Page(BasePage):
File "/media/wni/study/workspace4320151111/weichun/mezzanine/core/models.py", line 350, in __new__
return super(OrderableBase, cls).__new__(cls, name, bases, attrs)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/base.py", line 298, in __new__
new_class.add_to_class(field.name, copy.deepcopy(field))
File "/usr/local/lib/python2.7/dist-packages/django/db/models/base.py", line 324, in add_to_class
value.contribute_to_class(cls, name)
File "/media/wni/study/workspace4320151111/weichun/mezzanine/generic/fields.py", line 226, in contribute_to_class
super(KeywordsField, self).contribute_to_class(cls, name)
File "/media/wni/study/workspace4320151111/weichun/mezzanine/generic/fields.py", line 84, in contribute_to_class
cls._meta.get_fields_with_model()]:
File "/usr/local/lib/python2.7/dist-packages/django/db/models/options.py", line 56, in wrapper
return fn(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/options.py", line 432, in get_fields_with_model
return [self._map_model(f) for f in self.get_fields()]
File "/usr/local/lib/python2.7/dist-packages/django/db/models/options.py", line 740, in get_fields
return self._get_fields(include_parents=include_parents, include_hidden=include_hidden)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/options.py", line 802, in _get_fields
all_fields = self._relation_tree
File "/usr/local/lib/python2.7/dist-packages/django/utils/functional.py", line 60, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/options.py", line 709, in _relation_tree
return self._populate_directed_relation_graph()
File "/usr/local/lib/python2.7/dist-packages/django/db/models/options.py", line 681, in _populate_directed_relation_graph
all_models = self.apps.get_models(include_auto_created=True)
File "/usr/local/lib/python2.7/dist-packages/django/utils/lru_cache.py", line 101, in wrapper
result = user_function(*args, **kwds)
File "/usr/local/lib/python2.7/dist-packages/django/apps/registry.py", line 168, in get_models
self.check_models_ready()
File "/usr/local/lib/python2.7/dist-packages/django/apps/registry.py", line 131, in check_models_ready
raise AppRegistryNotReady("Models aren't loaded yet.")
django.core.exceptions.AppRegistryNotReady: Models aren't loaded yet.
Anyone knows how to fix it?
Thanks.
Wesley
I think you need to change your wsgi.py file as you go for different version of Django.
import os
import sys
from django.core.handlers.wsgi import WSGIHandler
os.environ['DJANGO_SETTINGS_MODULE'] = 'YourAppName.settings'
application = WSGIHandler()
And try to comment all third party application imported in settings.py.
1] ./manage.py runserver will use your wsgi.py however it looks like the stack trace you've shown at the top does not include the wsgi file. Therefore the error is occurring before the wsgi file is loaded.
2] This could well be an issue with your Django settings. For example,may in LOGGING a filename in a non-existent directory.
3] or check this

Error with admin.autodiscover in production

Trying to run into production django-project. On the development everything works well. On the production I've got 500 error
Here is Stack trace:
File "/home/megatexp/virtualenv/megatex__new_djangosites/2.7/lib/python2.7/site-packages/django/utils/translation/trans_real.py", line 164, in _add_installed_apps_translations
File "/home/megatexp/virtualenv/megatex__new_djangosites/2.7/lib/python2.7/site-packages/django/utils/translation/trans_real.py", line 116, in __init__
File "/home/megatexp/virtualenv/megatex__new_djangosites/2.7/lib/python2.7/site-packages/django/utils/translation/trans_real.py", line 206, in translation
File "/home/megatexp/virtualenv/megatex__new_djangosites/2.7/lib/python2.7/site-packages/django/utils/translation/trans_real.py", line 304, in do_translate
File "/home/megatexp/virtualenv/megatex__new_djangosites/2.7/lib/python2.7/site-packages/django/utils/translation/trans_real.py", line 327, in ugettext
File "/home/megatexp/virtualenv/megatex__new_djangosites/2.7/lib/python2.7/site-packages/django/utils/translation/__init__.py", line 84, in ugettext
File "/home/megatexp/virtualenv/megatex__new_djangosites/2.7/lib/python2.7/site-packages/django/utils/functional.py", line 141, in __text_cast
File "/home/megatexp/virtualenv/megatex__new_djangosites/2.7/lib/python2.7/site-packages/django/utils/encoding.py", line 92, in force_text
File "/home/megatexp/virtualenv/megatex__new_djangosites/2.7/lib/python2.7/site-packages/django/utils/dateformat.py", line 37, in format
File "/home/megatexp/virtualenv/megatex__new_djangosites/2.7/lib/python2.7/site-packages/django/utils/dateformat.py", line 270, in r
File "/home/megatexp/virtualenv/megatex__new_djangosites/2.7/lib/python2.7/site-packages/django/utils/dateformat.py", line 37, in format
File "/home/megatexp/virtualenv/megatex__new_djangosites/2.7/lib/python2.7/site-packages/django/utils/dateformat.py", line 345, in format
File "/home/megatexp/virtualenv/megatex__new_djangosites/2.7/lib/python2.7/site-packages/django/template/defaultfilters.py", line 774, in date
File "/home/megatexp/virtualenv/megatex__new_djangosites/2.7/lib/python2.7/site-packages/django/template/base.py", line 674, in resolve
File "/home/megatexp/virtualenv/megatex__new_djangosites/2.7/lib/python2.7/site-packages/django/template/debug.py", line 89, in render
File "/home/megatexp/virtualenv/megatex__new_djangosites/2.7/lib/python2.7/site-packages/django/template/debug.py", line 79, in render_node
File "/home/megatexp/virtualenv/megatex__new_djangosites/2.7/lib/python2.7/site-packages/django/template/base.py", line 903, in render
File "/home/megatexp/virtualenv/megatex__new_djangosites/2.7/lib/python2.7/site-packages/django/template/base.py", line 201, in _render
File "/home/megatexp/virtualenv/megatex__new_djangosites/2.7/lib/python2.7/site-packages/django/template/base.py", line 209, in render
File "/home/megatexp/virtualenv/megatex__new_djangosites/2.7/lib/python2.7/site-packages/django/views/debug.py", line 384, in get_traceback_html
File "/home/megatexp/virtualenv/megatex__new_djangosites/2.7/lib/python2.7/site-packages/django/views/debug.py", line 97, in technical_500_response
File "/home/megatexp/virtualenv/megatex__new_djangosites/2.7/lib/python2.7/site-packages/django/core/handlers/base.py", line 261, in handle_uncaught_exception
File "/home/megatexp/virtualenv/megatex__new_djangosites/2.7/lib/python2.7/site-packages/django/core/handlers/base.py", line 218, in get_response
File "/home/megatexp/virtualenv/megatex__new_djangosites/2.7/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 189, in __call__
File "/home/megatexp/virtualenv/megatex__new_djangosites/2.7/lib/python2.7/site-packages/django/apps/registry.py", line 124, in check_apps_ready
File "/home/megatexp/virtualenv/megatex__new_djangosites/2.7/lib/python2.7/site-packages/django/apps/registry.py", line 137, in get_app_configs
File "/home/megatexp/virtualenv/megatex__new_djangosites/2.7/lib/python2.7/site-packages/django/utils/module_loading.py", line 67, in autodiscover_modules
File "/home/megatexp/virtualenv/megatex__new_djangosites/2.7/lib/python2.7/site-packages/django/contrib/admin/__init__.py", line 24, in autodiscover
File "/home/megatexp/megatex_new/djangosites/megatex_new/megatex_new/urls.py", line 25, in <module>
File "/home/megatexp/virtualenv/megatex__new_djangosites/2.7/lib/python2.7/site-packages/django/core/urlresolvers.py", line 396, in urlconf_module
File "/home/megatexp/virtualenv/megatex__new_djangosites/2.7/lib/python2.7/site-packages/django/core/urlresolvers.py", line 402, in url_patterns
File "/home/megatexp/virtualenv/megatex__new_djangosites/2.7/lib/python2.7/site-packages/django/core/urlresolvers.py", line 366, in resolve
File "/home/megatexp/virtualenv/megatex__new_djangosites/2.7/lib/python2.7/site-packages/django/core/handlers/base.py", line 119, in get_response
And global urls.py file:
from django.conf.urls import include, url
from django.contrib import admin
from articles.views import ArticleView
from shop.views import HomeView
from feedback.views import *
from django.conf import settings
from django.conf.urls.static import static
admin.autodiscover()
urlpatterns = [
url(r'^ckeditor/', include('ckeditor.urls')),
url(r'^admin/', include(admin.site.urls)),
url(r'^shop/', include('shop.urls')),
url(r'^about/$', ArticleView.as_view(slug="Про нас"), name='about'),
url(r'^feedback/', include('feedback.urls')),
url(r'^captcha/', include('captcha.urls')),
url(r'^$', HomeView.as_view(), name='home'),
]
DEBUG = True in settings.
Also app is running not on the root of the domain. Maybe it cause some problems with autodiscover. Thus I also have added FORCE_SCRIPT_NAME, but the result is the same: 500 internal server error.
I've tried to remove admin.autodiscover() from urls.py but I still got 500 error.
Here is stack
File "/home/megatexp/virtualenv/megatex__new_djangosites/2.7/lib/python2.7/site-packages/django/utils/translation/trans_real.py", line 164, in _add_installed_apps_translations
File "/home/megatexp/virtualenv/megatex__new_djangosites/2.7/lib/python2.7/site-packages/django/utils/translation/trans_real.py", line 116, in __init__
File "/home/megatexp/virtualenv/megatex__new_djangosites/2.7/lib/python2.7/site-packages/django/utils/translation/trans_real.py", line 206, in translation
File "/home/megatexp/virtualenv/megatex__new_djangosites/2.7/lib/python2.7/site-packages/django/utils/translation/trans_real.py", line 304, in do_translate
File "/home/megatexp/virtualenv/megatex__new_djangosites/2.7/lib/python2.7/site-packages/django/utils/translation/trans_real.py", line 327, in ugettext
File "/home/megatexp/virtualenv/megatex__new_djangosites/2.7/lib/python2.7/site-packages/django/utils/translation/__init__.py", line 84, in ugettext
File "/home/megatexp/virtualenv/megatex__new_djangosites/2.7/lib/python2.7/site-packages/django/utils/functional.py", line 141, in __text_cast
File "/home/megatexp/virtualenv/megatex__new_djangosites/2.7/lib/python2.7/site-packages/django/utils/encoding.py", line 92, in force_text
File "/home/megatexp/virtualenv/megatex__new_djangosites/2.7/lib/python2.7/site-packages/django/utils/dateformat.py", line 37, in format
File "/home/megatexp/virtualenv/megatex__new_djangosites/2.7/lib/python2.7/site-packages/django/utils/dateformat.py", line 270, in r
File "/home/megatexp/virtualenv/megatex__new_djangosites/2.7/lib/python2.7/site-packages/django/utils/dateformat.py", line 37, in format
File "/home/megatexp/virtualenv/megatex__new_djangosites/2.7/lib/python2.7/site-packages/django/utils/dateformat.py", line 345, in format
File "/home/megatexp/virtualenv/megatex__new_djangosites/2.7/lib/python2.7/site-packages/django/template/defaultfilters.py", line 774, in date
File "/home/megatexp/virtualenv/megatex__new_djangosites/2.7/lib/python2.7/site-packages/django/template/base.py", line 674, in resolve
File "/home/megatexp/virtualenv/megatex__new_djangosites/2.7/lib/python2.7/site-packages/django/template/debug.py", line 89, in render
File "/home/megatexp/virtualenv/megatex__new_djangosites/2.7/lib/python2.7/site-packages/django/template/debug.py", line 79, in render_node
File "/home/megatexp/virtualenv/megatex__new_djangosites/2.7/lib/python2.7/site-packages/django/template/base.py", line 903, in render
File "/home/megatexp/virtualenv/megatex__new_djangosites/2.7/lib/python2.7/site-packages/django/template/base.py", line 201, in _render
File "/home/megatexp/virtualenv/megatex__new_djangosites/2.7/lib/python2.7/site-packages/django/template/base.py", line 209, in render
File "/home/megatexp/virtualenv/megatex__new_djangosites/2.7/lib/python2.7/site-packages/django/views/debug.py", line 384, in get_traceback_html
File "/home/megatexp/virtualenv/megatex__new_djangosites/2.7/lib/python2.7/site-packages/django/views/debug.py", line 97, in technical_500_response
File "/home/megatexp/virtualenv/megatex__new_djangosites/2.7/lib/python2.7/site-packages/django/core/handlers/base.py", line 261, in handle_uncaught_exception
File "/home/megatexp/virtualenv/megatex__new_djangosites/2.7/lib/python2.7/site-packages/django/core/handlers/base.py", line 218, in get_response
File "/home/megatexp/virtualenv/megatex__new_djangosites/2.7/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 189, in __call__
File "/home/megatexp/virtualenv/megatex__new_djangosites/2.7/lib/python2.7/site-packages/django/apps/registry.py", line 124, in check_apps_ready
File "/home/megatexp/virtualenv/megatex__new_djangosites/2.7/lib/python2.7/site-packages/django/apps/registry.py", line 231, in is_installed
File "/home/megatexp/virtualenv/megatex__new_djangosites/2.7/lib/python2.7/site-packages/django/contrib/admin/sites.py", line 171, in check_dependencies
File "/home/megatexp/virtualenv/megatex__new_djangosites/2.7/lib/python2.7/site-packages/django/contrib/admin/sites.py", line 250, in get_urls
File "/home/megatexp/virtualenv/megatex__new_djangosites/2.7/lib/python2.7/site-packages/django/contrib/admin/sites.py", line 291, in urls
File "/home/megatexp/megatex_new/djangosites/megatex_new/megatex_new/urls.py", line 27, in <module>
File "/home/megatexp/virtualenv/megatex__new_djangosites/2.7/lib/python2.7/site-packages/django/core/urlresolvers.py", line 396, in urlconf_module
File "/home/megatexp/virtualenv/megatex__new_djangosites/2.7/lib/python2.7/site-packages/django/core/urlresolvers.py", line 402, in url_patterns
File "/home/megatexp/virtualenv/megatex__new_djangosites/2.7/lib/python2.7/site-packages/django/core/urlresolvers.py", line 366, in resolve
File "/home/megatexp/virtualenv/megatex__new_djangosites/2.7/lib/python2.7/site-packages/django/core/handlers/base.py", line 119, in get_response
It can not resolve admin.urls
Looks like misconfiguration on server, but what is the exact problem I can not determine. I ran this project on local apache with mod_wsgi and all is ok. When I tested it on production server I faced with this situation.

Running Django Tests with a Precommit Hook

I would like to run all my django tests using mercurial's precommit hook. Whenever a test fails the commit will be aborted.
The goal is to block build-breaking commits as often as possible.
edit: Ended up using the external script route. Here is the reletant portion of my hgrc:
[hooks]
precommit = python ./pinax/projects/lgr/manage.py test lgr_photos --verbosity=0 --noinput
commit = hg push
Here is my progress on the hook function:
from os.path import join, dirname
import sys
from django.core.management import call_command
def hook(ui, repo, **kwargs):
project_path = join( dirname(repo.path), 'pinax', 'projects')
sys.path.insert(0, project_path)
from lgr.manage import *
output = call_command('test', verbosity=0, interactive=False)
#ui.warn(output)
What am I doing wrong here?
PS - It's giving a HUGE error traceback, which is included in it's entirety below
jim#ubuntu:~/workspace/lgr$ hg ci -m 'testing hooks'
No username found, using 'jim#ubuntu.ubuntu-domain' instead
error: precommit hook raised an exception: '_demandmod' object is not iterable
** unknown exception encountered, details follow
** report bug details to http://mercurial.selenic.com/bts/
** or mercurial#selenic.com
** Mercurial Distributed SCM (version 1.3.1)
** Extensions loaded:
Traceback (most recent call last):
File "/usr/bin/hg", line 27, in <module>
mercurial.dispatch.run()
File "/usr/lib/pymodules/python2.6/mercurial/dispatch.py", line 16, in run
sys.exit(dispatch(sys.argv[1:]))
File "/usr/lib/pymodules/python2.6/mercurial/dispatch.py", line 27, in dispatch
return _runcatch(u, args)
File "/usr/lib/pymodules/python2.6/mercurial/dispatch.py", line 43, in _runcatch
return _dispatch(ui, args)
File "/usr/lib/pymodules/python2.6/mercurial/dispatch.py", line 449, in _dispatch
return runcommand(lui, repo, cmd, fullargs, ui, options, d)
File "/usr/lib/pymodules/python2.6/mercurial/dispatch.py", line 317, in runcommand
ret = _runcommand(ui, options, cmd, d)
File "/usr/lib/pymodules/python2.6/mercurial/dispatch.py", line 501, in _runcommand
return checkargs()
File "/usr/lib/pymodules/python2.6/mercurial/dispatch.py", line 454, in checkargs
return cmdfunc()
File "/usr/lib/pymodules/python2.6/mercurial/dispatch.py", line 448, in <lambda>
d = lambda: util.checksignature(func)(ui, *args, **cmdoptions)
File "/usr/lib/pymodules/python2.6/mercurial/util.py", line 402, in check
return func(*args, **kwargs)
File "/usr/lib/pymodules/python2.6/mercurial/commands.py", line 667, in commit
node = cmdutil.commit(ui, repo, commitfunc, pats, opts)
File "/usr/lib/pymodules/python2.6/mercurial/cmdutil.py", line 1213, in commit
return commitfunc(ui, repo, message, match(repo, pats, opts), opts)
File "/usr/lib/pymodules/python2.6/mercurial/commands.py", line 665, in commitfunc
editor=e, extra=extra)
File "/usr/lib/pymodules/python2.6/mercurial/localrepo.py", line 886, in commit
ret = self.commitctx(cctx, True)
File "/usr/lib/pymodules/python2.6/mercurial/localrepo.py", line 915, in commitctx
self.hook("precommit", throw=True, parent1=xp1, parent2=xp2)
File "/usr/lib/pymodules/python2.6/mercurial/localrepo.py", line 139, in hook
return hook.hook(self.ui, self, name, throw, **args)
File "/usr/lib/pymodules/python2.6/mercurial/hook.py", line 119, in hook
r = _pythonhook(ui, repo, name, hname, hookfn, args, throw) or r
File "/usr/lib/pymodules/python2.6/mercurial/hook.py", line 52, in _pythonhook
r = obj(ui=ui, repo=repo, hooktype=name, **args)
here is the important part:
File "/home/jim/run_lgr_tests.py", line 11, in hook
output = call_command('test', verbosity=0, interactive=False)
and the rest:
File "/usr/local/lib/python2.6/dist-packages/django/core/management/__init__.py", line 166, in call_command
return klass.execute(*args, **defaults)
File "/usr/local/lib/python2.6/dist-packages/django/core/management/base.py", line 213, in execute
translation.activate('en-us')
File "/usr/local/lib/python2.6/dist-packages/django/utils/translation/__init__.py", line 73, in activate
return real_activate(language)
File "/usr/local/lib/python2.6/dist-packages/django/utils/translation/__init__.py", line 43, in delayed_loader
return g['real_%s' % caller](*args, **kwargs)
File "/usr/local/lib/python2.6/dist-packages/django/utils/translation/trans_real.py", line 205, in activate
_active[currentThread()] = translation(language)
File "/usr/local/lib/python2.6/dist-packages/django/utils/translation/trans_real.py", line 194, in translation
default_translation = _fetch(settings.LANGUAGE_CODE)
File "/usr/local/lib/python2.6/dist-packages/django/utils/translation/trans_real.py", line 180, in _fetch
app = import_module(appname)
File "/usr/local/lib/python2.6/dist-packages/django/utils/importlib.py", line 35, in import_module
__import__(name)
File "/usr/lib/pymodules/python2.6/mercurial/demandimport.py", line 84, in _demandimport
return _origimport(name, globals, locals, fromlist)
File "/home/jim/workspace/lgr/pinax/projects/lgr/apps/lgr_hacks.py", line 5, in <module>
User.email = models.EmailField(_('email address'), blank=True, max_length=200)
File "/usr/local/lib/python2.6/dist-packages/django/utils/translation/__init__.py", line 62, in ugettext
return real_ugettext(message)
File "/usr/local/lib/python2.6/dist-packages/django/utils/translation/trans_real.py", line 286, in ugettext
return do_translate(message, 'ugettext')
File "/usr/local/lib/python2.6/dist-packages/django/utils/translation/trans_real.py", line 276, in do_translate
_default = translation(settings.LANGUAGE_CODE)
File "/usr/local/lib/python2.6/dist-packages/django/utils/translation/trans_real.py", line 194, in translation
default_translation = _fetch(settings.LANGUAGE_CODE)
File "/usr/local/lib/python2.6/dist-packages/django/utils/translation/trans_real.py", line 180, in _fetch
app = import_module(appname)
File "/usr/local/lib/python2.6/dist-packages/django/utils/importlib.py", line 35, in import_module
__import__(name)
File "/usr/lib/pymodules/python2.6/mercurial/demandimport.py", line 84, in _demandimport
return _origimport(name, globals, locals, fromlist)
File "/home/jim/workspace/lgr/pinax/apps/external_apps/djangodblog/__init__.py", line 1, in <module>
import djangodblog.admin
File "/usr/lib/pymodules/python2.6/mercurial/demandimport.py", line 91, in _demandimport
return _origimport(name, globals, locals, fromlist)
File "/home/jim/workspace/lgr/pinax/apps/external_apps/djangodblog/admin.py", line 14, in <module>
admin.site.register(ErrorBatch, ErrorBatchAdmin)
File "/usr/local/lib/python2.6/dist-packages/django/contrib/admin/sites.py", line 90, in register
validate(admin_class, model)
File "/usr/local/lib/python2.6/dist-packages/django/contrib/admin/validation.py", line 22, in validate
models.get_apps()
File "/usr/local/lib/python2.6/dist-packages/django/db/models/loading.py", line 100, in get_apps
self._populate()
File "/usr/local/lib/python2.6/dist-packages/django/db/models/loading.py", line 58, in _populate
self.load_app(app_name, True)
File "/usr/local/lib/python2.6/dist-packages/django/db/models/loading.py", line 74, in load_app
models = import_module('.models', app_name)
File "/usr/local/lib/python2.6/dist-packages/django/utils/importlib.py", line 35, in import_module
__import__(name)
File "/usr/lib/pymodules/python2.6/mercurial/demandimport.py", line 84, in _demandimport
return _origimport(name, globals, locals, fromlist)
File "/home/jim/workspace/lgr/pinax/projects/lgr/apps/account/models.py", line 7, in <module>
from timezones.fields import TimeZoneField
File "/usr/lib/pymodules/python2.6/mercurial/demandimport.py", line 103, in _demandimport
mod = _origimport(name, globals, locals)
File "/home/jim/workspace/lgr/pinax/apps/external_apps/timezones/fields.py", line 12, in <module>
default_tz = pytz.timezone(getattr(settings, "TIME_ZONE", "UTC"))
File "/usr/lib/pymodules/python2.6/mercurial/demandimport.py", line 75, in __getattribute__
self._load()
File "/usr/lib/pymodules/python2.6/mercurial/demandimport.py", line 47, in _load
mod = _origimport(head, globals, locals)
File "/home/jim/workspace/lgr/pinax/libs/external_libs/pytz-2008b/pytz/__init__.py", line 29, in <module>
from pkg_resources import resource_stream
File "/usr/lib/pymodules/python2.6/mercurial/demandimport.py", line 103, in _demandimport
mod = _origimport(name, globals, locals)
File "/usr/lib/python2.6/dist-packages/pkg_resources.py", line 2562, in <module>
working_set.require(__requires__)
File "/usr/lib/python2.6/dist-packages/pkg_resources.py", line 626, in require
needed = self.resolve(parse_requirements(requirements))
File "/usr/lib/python2.6/dist-packages/pkg_resources.py", line 505, in resolve
requirements = list(requirements)[::-1] # set up the stack
File "/usr/lib/python2.6/dist-packages/pkg_resources.py", line 2380, in parse_requirements
for line in lines:
File "/usr/lib/python2.6/dist-packages/pkg_resources.py", line 1814, in yield_lines
for s in yield_lines(ss):
File "/usr/lib/python2.6/dist-packages/pkg_resources.py", line 1813, in yield_lines
for ss in strs:
TypeError: '_demandmod' object is not iterable
It looks like Mercurial's way of importing modules is clashing with Django's somehow.
Before trying to dive in and sort that out, is there any reason to not just run the tests with the normal command?
[hooks]
precommit.runtests = python manage.py test

Categories