*Found the error:*
I installed modal_announcements module Looong ago; since I wanted to modify
it, I then copied the code to my project and adopted it as needed; it did
not give me errors.
But after installing celery it somehow picked the old modal_announcement's
urls (or views, or whatever...) from .virtualenv instead of my project and
exposed the error to me in this tricky way. Took me ages to figure out!
Morale: clear up properly!
On Sunday, October 22, 2017 at 9:49:09 AM UTC+9, Andrey inte wrote:
>
> The site works ok, but when a celery task is called which renderes
> template for EmailMultiAlternatives, I get ImportError: No module named
> urls. If I comment out just one app in settings.py (modal_announcements),
> it works. The app itself runs ok in the site. This is the urls.py (which
> could not be found, thoght it apparently exists):
>
> from django.conf.urls import patterns, url
> from mezzanine.conf import settings
> from modal_announcements.views import announcement
>
> urlpatterns = patterns('',
> url("^announcement/(?P<pk>.*)%s$" % ("/" if
> settings.APPEND_SLASH else ""), announcement,
> name='announcement')
> )
> here are the project's urls:
>
> if settings.USE_MODELTRANSLATION:
> urlpatterns += patterns('',
> url('^i18n/$', 'django.views.i18n.set_language',
> name='set_language'),
> url(r'^robots\.txt$',
> TemplateView.as_view(template_name='robots.txt',
>
> content_type='text/plain')),
>
> url(r'^chaining/', include('smart_selects.urls')),
> )
>
> urlpatterns += i18n_patterns("",
> url("^$", home, name='home'),
> url(r'^inliner$',
> inliner, name='inliner'),
> url(r'^autocomplete/',
> include('autocomplete_light.urls')),
> ("^orders/",
> include("orders.urls", namespace="orders")),
> ("^shop/",
> include("shop.urls", namespace="shop")),
> ("^programs/",
> include("programs.urls", namespace="programs")),
> ("^prices/",
> include("prices.urls", namespace="prices")),
> ("^tour/", include("tour.urls", namespace="tour")),
> ("^misc/", include("misc.urls", namespace="misc")),
> **("^announcements/",
> include("modal_announcements.urls", namespace="announcements")),**
> ("^%s/" %
> settings.EVENT_SLUG,
> include("mezzanine_agenda.urls")),
> # ``mezzanine.urls``.
> ("^", include("mezzanine.urls")),
>
> )
>
>
> urlpatterns += patterns('',
> url('', include('social.apps.django_app.urls', namespace='social')),
> )
> # Adds ``STATIC_URL`` to the context of error pages, so that error
> # pages can use JS, CSS and images.
> handler404 = "mezzanine.core.views.page_not_found"
> handler500 = "mezzanine.core.views.server_error"
>
> if settings.DEBUG:
> import debug_toolbar
> urlpatterns += patterns('',
> url(r'^__debug__/', include(debug_toolbar.urls)),
> )
> traceback:
>
> [2017-10-22 01:43:47,493: INFO/MainProcess] Received task:
> send_mail_template_task[abb16580-9037-4bd9-9f5c-75f85e6a51b4]
> [2017-10-22 01:43:47,576: ERROR/ForkPoolWorker-1] Task
> send_mail_template_task[abb16580-9037-4bd9-9f5c-75f85e6a51b4] raised
> unexpected: ImportError('No module named urls',) Traceback (most recent
> call last): File
> "/home/andy/.virtualenvs/stable/local/lib/python2.7/site-packages/celery/app/trace.py",
>
> line 374, in trace_task R = retval = fun(*args, **kwargs) File
> "/home/andy/.virtualenvs/stable/local/lib/python2.7/site-packages/celery/app/trace.py",
>
> line 629, in protected_call return self.run(*args, **kwargs) File
> "/home/andy/stable/inte-production/misc/tasks.py", line 14, in
> send_mail_template_task headers=None) File
> "/home/andy/stable/inte-production/misc/utils.py", line 277, in
> send_mail_template msg.attach_alternative(t.render(context),"text/html")
> File
> "/home/andy/.virtualenvs/stable/local/lib/python2.7/site-packages/django/template/backends/django.py",
>
> line 74, in render return self.template.render(context) File
> "/home/andy/.virtualenvs/stable/local/lib/python2.7/site-packages/django/template/base.py",
>
> line 210, in render return self._render(context) File
> "/home/andy/.virtualenvs/stable/local/lib/python2.7/site-packages/django/template/base.py",
>
> line 202, in _render return self.nodelist.render(context) File
> "/home/andy/.virtualenvs/stable/local/lib/python2.7/site-packages/django/template/base.py",
>
> line 905, in render bit = self.render_node(node, context) File
> "/home/andy/.virtualenvs/stable/local/lib/python2.7/site-packages/django/template/debug.py",
>
> line 79, in render_node return node.render(context) File
> "/home/andy/.virtualenvs/stable/local/lib/python2.7/site-packages/django/template/defaulttags.py",
>
> line 493, in render url = reverse(view_name, args=args, kwargs=kwargs,
> current_app=current_app) File
> "/home/andy/.virtualenvs/stable/local/lib/python2.7/site-packages/django/core/urlresolvers.py",
>
> line 578, in reverse return
> force_text(iri_to_uri(resolver._reverse_with_prefix(view, prefix, *args,
> **kwargs))) File
> "/home/andy/.virtualenvs/stable/local/lib/python2.7/site-packages/django/core/urlresolvers.py",
>
> line 432, in _reverse_with_prefix self._populate() File
> "/home/andy/.virtualenvs/stable/local/lib/python2.7/site-packages/django/core/urlresolvers.py",
>
> line 284, in _populate for pattern in reversed(self.url_patterns): File
> "/home/andy/.virtualenvs/stable/local/lib/python2.7/site-packages/django/core/urlresolvers.py",
>
> line 401, in url_patterns patterns = getattr(self.urlconf_module,
> "urlpatterns", self.urlconf_module) File
> "/home/andy/.virtualenvs/stable/local/lib/python2.7/site-packages/django/core/urlresolvers.py",
>
> line 395, in urlconf_module self._urlconf_module =
> import_module(self.urlconf_name) File
> "/usr/lib/python2.7/importlib/init.py", line 37, in import_module
> import(name) File "/home/andy/stable/inte-production/inte/urls.py", line
> 273, in ("^announcements/", include("modal_announcements.urls",
> namespace="announcements")), File
> "/home/andy/.virtualenvs/stable/local/lib/python2.7/site-packages/django/conf/urls/init.py",
>
> line 33, in include urlconf_module = import_module(urlconf_module) File
> "/usr/lib/python2.7/importlib/init.py", line 37, in import_module
> import(name) ImportError: No module named urls
--
You received this message because you are subscribed to the Google Groups
"Mezzanine Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.