4

我刚刚从头开始重新安装了 Django 和 Django-CMS(包括全新的 virtualenv 和 python 构建)。我收到了这个奇怪的错误.. 谷歌一直没有帮助。想法?

TemplateSyntaxError at /
Caught AttributeError while rendering: 'str' object has no attribute 'regex'

In template /Users/bdunlay/python/python-2.5/lib/python2.5/site-packages/django_cms2.1.0.beta3-py2.5.egg/cms/templates/cms/new.html, error at line 37

这是行:

37: <li>Log into <a href="{% url admin:index %}">admin</a> and <a href="{% url pages-root %}admin/cms/page/add/">add</a> some pages.</li>

更多东西

/Users/bdunlay/python/python-2.5/lib/python2.5/site-packages/Django-1.3-py2.5.egg/django/core/urlresolvers.py in _populate
    return '<%s %s (%s:%s) %s>' % (self.__class__.__name__, self.urlconf_name, self.app_name, self.namespace, self.regex.pattern)
def _populate(self):
    lookups = MultiValueDict()
    namespaces = {}
    apps = {}
    for pattern in reversed(self.url_patterns):
-->     p_pattern = pattern.regex.pattern ...
        if p_pattern.startswith('^'):
            p_pattern = p_pattern[1:]
        if isinstance(pattern, RegexURLResolver):
            if pattern.namespace:
                namespaces[pattern.namespace] = (p_pattern, pattern)
                if pattern.app_name:
4

1 回答 1

16

刚刚出现这个错误。在我的情况下,它是由 urls.py 模式中的三重引号字符串(注释)引起的。
实际上它并没有被解释为注释而是被传递给函数!

于 2011-07-16T17:45:22.480 回答