willhardy / django-seo

Provides a set of tools for managing Search Engine Optimisation (SEO) for Django sites.
BSD 3-Clause "New" or "Revised" License
253 stars 117 forks source link

TemplateSyntaxError: {% get_metadata %} needs some path information SHOW When set Debug=False,but set to True, no error out. #38

Open kingctan opened 11 years ago

kingctan commented 11 years ago

Traceback (most recent call last): File "/usr/lib64/python2.6/wsgiref/handlers.py", line 93, in run self.result = application(self.environ, self.start_response) File "/home/33pinche/33pinche/lib/python2.6/site-packages/django/core/handlers/wsgi.py", line 255, in call response = self.get_response(request) File "/home/33pinche/33pinche/lib/python2.6/site-packages/django/core/handlers/base.py", line 178, in get_response response = self.handle_uncaught_exception(request, resolver, sys.exc_info()) File "/home/33pinche/33pinche/lib/python2.6/site-packages/django/core/handlers/base.py", line 224, in handle_uncaught_exception return callback(request, _param_dict) File "/home/33pinche/33pinche/lib/python2.6/site-packages/django/utils/decorators.py", line 91, in _wrapped_view response = view_func(request, args, _kwargs) File "/home/33pinche/33pinche/lib/python2.6/site-packages/django/views/defaults.py", line 41, in server_error return http.HttpResponseServerError(template.render(Context({}))) File "/home/33pinche/33pinche/lib/python2.6/site-packages/django/template/base.py", line 140, in render return self._render(context) File "/home/33pinche/33pinche/lib/python2.6/site-packages/django/template/base.py", line 134, in _render return self.nodelist.render(context) File "/home/33pinche/33pinche/lib/python2.6/site-packages/django/template/base.py", line 830, in render bit = self.render_node(node, context) File "/home/33pinche/33pinche/lib/python2.6/site-packages/django/template/base.py", line 844, in render_node return node.render(context) File "/home/33pinche/33pinche/lib/python2.6/site-packages/django/template/loader_tags.py", line 124, in render return compiled_parent._render(context) File "/home/33pinche/33pinche/lib/python2.6/site-packages/django/template/base.py", line 134, in _render return self.nodelist.render(context) File "/home/33pinche/33pinche/lib/python2.6/site-packages/django/template/base.py", line 830, in render bit = self.render_node(node, context) File "/home/33pinche/33pinche/lib/python2.6/site-packages/django/template/base.py", line 844, in render_node return node.render(context) File "/home/33pinche/33pinche/project/rollyourown/seo/templatetags/seo.py", line 25, in render raise template.TemplateSyntaxError(msg) TemplateSyntaxError: {% get_metadata %} needs some path information. Please use RequestContext with the django.core.context_processors.request context processor. Or provide a path or object explicitly, eg {% get_metadata for path %} or {% get_metadata for object %} [24/May/2013 07:45:56] "GET / HTTP/1.1" 500 59 Traceback (most recent call last): File "/usr/lib64/python2.6/wsgiref/handlers.py", line 93, in run self.result = application(self.environ, self.start_response) File "/home/33pinche/33pinche/lib/python2.6/site-packages/django/core/handlers/wsgi.py", line 255, in call response = self.get_response(request) File "/home/33pinche/33pinche/lib/python2.6/site-packages/django/core/handlers/base.py", line 178, in get_response response = self.handle_uncaught_exception(request, resolver, sys.exc_info()) File "/home/33pinche/33pinche/lib/python2.6/site-packages/django/core/handlers/base.py", line 224, in handle_uncaught_exception return callback(request, _param_dict) File "/home/33pinche/33pinche/lib/python2.6/site-packages/django/utils/decorators.py", line 91, in _wrapped_view response = view_func(request, args, _kwargs) File "/home/33pinche/33pinche/lib/python2.6/site-packages/django/views/defaults.py", line 41, in server_error return http.HttpResponseServerError(template.render(Context({}))) File "/home/33pinche/33pinche/lib/python2.6/site-packages/django/template/base.py", line 140, in render return self._render(context) File "/home/33pinche/33pinche/lib/python2.6/site-packages/django/template/base.py", line 134, in _render return self.nodelist.render(context) File "/home/33pinche/33pinche/lib/python2.6/site-packages/django/template/base.py", line 830, in render bit = self.render_node(node, context) File "/home/33pinche/33pinche/lib/python2.6/site-packages/django/template/base.py", line 844, in render_node return node.render(context) File "/home/33pinche/33pinche/lib/python2.6/site-packages/django/template/loader_tags.py", line 124, in render return compiled_parent._render(context) File "/home/33pinche/33pinche/lib/python2.6/site-packages/django/template/base.py", line 134, in _render return self.nodelist.render(context) File "/home/33pinche/33pinche/lib/python2.6/site-packages/django/template/base.py", line 830, in render bit = self.render_node(node, context) File "/home/33pinche/33pinche/lib/python2.6/site-packages/django/template/base.py", line 844, in render_node return node.render(context) File "/home/33pinche/33pinche/project/rollyourown/seo/templatetags/seo.py", line 25, in render raise template.TemplateSyntaxError(msg) TemplateSyntaxError: {% get_metadata %} needs some path information. Please use RequestContext with the django.core.context_processors.request context processor. Or provide a path or object explicitly, eg {% get_metadata for path %} or {% get_metadata for object %}

beholderrk commented 11 years ago

context_processors.request is added to TEMPLATE_CONTEXT_PROCESSORS?

kingctan commented 11 years ago

Yes,I did.

AMongeMoreno commented 9 years ago

Anything on this?

cboothe commented 9 years ago

I had this issue with CBV in Django 1.6.11

Modified the templatetags/seo.py in def render(self, context) on line 20:

    try:
        if 'view' in context:
            target = self.target.resolve(context['view'])
        else:
            target = self.target.resolve(context)

    except VariableDoesNotExist: