2017-02-02 15 views
1

Я новичок в django-oscar, и это первый раз, когда я попытался запустить с ним веб-сайт. При попытке загрузить веб-страницу (localhost: 8000) я столкнулся со следующей трассировкой стека. Я пытался много искать в Интернете, но я не мог найти никакого решения.

Image Окружающая среда: Запрос Метод: GET URL запроса: http://localhost:8000/Django oscar Не удалось найти ключ [корзина] в <WSGIRequest GET>

Django Version: 1.9 
Python Version: 3.5.2 
Installed Applications: 
['django.contrib.admin', 
'django.contrib.auth', 
'django.contrib.contenttypes', 
'django.contrib.sessions', 
'django.contrib.messages', 
'django.contrib.staticfiles', 
'django.contrib.sites', 
'django.contrib.flatpages', 
'compressor', 
'widget_tweaks', 
'oscar', 
'oscar.apps.analytics', 
'oscar.apps.checkout', 
'oscar.apps.address', 
'oscar.apps.shipping', 
'oscar.apps.catalogue', 
'oscar.apps.catalogue.reviews', 
'oscar.apps.partner', 
'oscar.apps.basket', 
'oscar.apps.payment', 
'oscar.apps.offer', 
'oscar.apps.order', 
'oscar.apps.customer', 
'oscar.apps.promotions', 
'oscar.apps.search', 
'oscar.apps.voucher', 
'oscar.apps.wishlists', 
'oscar.apps.dashboard', 
'oscar.apps.dashboard.reports', 
'oscar.apps.dashboard.users', 
'oscar.apps.dashboard.orders', 
'oscar.apps.dashboard.promotions', 
'oscar.apps.dashboard.catalogue', 
'oscar.apps.dashboard.offers', 
'oscar.apps.dashboard.partners', 
'oscar.apps.dashboard.pages', 
'oscar.apps.dashboard.ranges', 
'oscar.apps.dashboard.reviews', 
'oscar.apps.dashboard.vouchers', 
'oscar.apps.dashboard.communications', 
'oscar.apps.dashboard.shipping', 
'haystack', 
'treebeard', 
'sorl.thumbnail', 
'django_tables2'] 

Installed Middleware:<br> 
['django.middleware.common.CommonMiddleware', 
'django.middleware.csrf.CsrfViewMiddleware'] 


Template error: 
In template 
/Users/rohit.rawat/.virtualenvs/env/lib/python3.5/site-packages/oscar/templates/oscar/promotions/home.html, error at line 0 
    Failed lookup for key [%s] in %r 1 : {% extends "layout_2_col.html" %} 
    2 : {% load i18n %} 
    3 : 
    4 : {% block navigation %} 
    5 :  {% include "partials/nav_primary.html" with expand_dropdown=1 %} 
    6 : {% endblock %} 
    7 : 
    8 : {% block header %}{% endblock %} 
    9 : 
    10 : {% block column_left %} 


Traceback: 

File "/Users/rohit.rawat/.virtualenvs/env/lib/python3.5/site-packages/django/template/base.py" in _resolve_lookup 
    879.      current = current[bit] 

During handling of the above exception ('WSGIRequest' object is not subscriptable), another exception occurred: 

File "/Users/rohit.rawat/.virtualenvs/env/lib/python3.5/site-packages/django/template/base.py" in _resolve_lookup 
    887.       current = getattr(current, bit) 

During handling of the above exception ('WSGIRequest' object has no attribute 'basket'), another exception occurred: 

File "/Users/rohit.rawat/.virtualenvs/env/lib/python3.5/site-packages/django/template/base.py" in _resolve_lookup 
    894.        current = current[int(bit)] 

During handling of the above exception (invalid literal for int() with base 10: 'basket'), another exception occurred: 

File "/Users/rohit.rawat/.virtualenvs/env/lib/python3.5/site-packages/django/core/handlers/base.py" in get_response 
    174.      response = self.process_exception_by_middleware(e, request) 

File "/Users/rohit.rawat/.virtualenvs/env/lib/python3.5/site-packages/django/core/handlers/base.py" in get_response 
    172.      response = response.render() 

File "/Users/rohit.rawat/.virtualenvs/env/lib/python3.5/site-packages/django/template/response.py" in render 
    160.    self.content = self.rendered_content 

File "/Users/rohit.rawat/.virtualenvs/env/lib/python3.5/site-packages/django/template/response.py" in rendered_content 
    137.   content = template.render(context, self._request) 

File "/Users/rohit.rawat/.virtualenvs/env/lib/python3.5/site-packages/django/template/backends/django.py" in render 
    95.    return self.template.render(context) 

File "/Users/rohit.rawat/.virtualenvs/env/lib/python3.5/site-packages/django/template/base.py" in render 
    206.      return self._render(context) 

File "/Users/rohit.rawat/.virtualenvs/env/lib/python3.5/site-packages/django/template/base.py" in _render 
    197.   return self.nodelist.render(context) 

File "/Users/rohit.rawat/.virtualenvs/env/lib/python3.5/site-packages/django/template/base.py" in render 
    988.     bit = node.render_annotated(context) 

File "/Users/rohit.rawat/.virtualenvs/env/lib/python3.5/site-packages/django/template/base.py" in render_annotated 
    955.    return self.render(context) 

File "/Users/rohit.rawat/.virtualenvs/env/lib/python3.5/site-packages/django/template/loader_tags.py" in render 
    173.   return compiled_parent._render(context) 

File "/Users/rohit.rawat/.virtualenvs/env/lib/python3.5/site-packages/django/template/base.py" in _render 
    197.   return self.nodelist.render(context) 

File "/Users/rohit.rawat/.virtualenvs/env/lib/python3.5/site-packages/django/template/base.py" in render 
    988.     bit = node.render_annotated(context) 

File "/Users/rohit.rawat/.virtualenvs/env/lib/python3.5/site-packages/django/template/base.py" in render_annotated 
    955.    return self.render(context) 

File "/Users/rohit.rawat/.virtualenvs/env/lib/python3.5/site-packages/django/template/loader_tags.py" in render 
    173.   return compiled_parent._render(context) 

File "/Users/rohit.rawat/.virtualenvs/env/lib/python3.5/site-packages/django/template/base.py" in _render 
    197.   return self.nodelist.render(context) 

File "/Users/rohit.rawat/.virtualenvs/env/lib/python3.5/site-packages/django/template/base.py" in render 
    988.     bit = node.render_annotated(context) 

File "/Users/rohit.rawat/.virtualenvs/env/lib/python3.5/site-packages/django/template/base.py" in render_annotated 
    955.    return self.render(context) 

File "/Users/rohit.rawat/.virtualenvs/env/lib/python3.5/site-packages/django/template/loader_tags.py" in render 
    173.   return compiled_parent._render(context) 

File "/Users/rohit.rawat/.virtualenvs/env/lib/python3.5/site-packages/django/template/base.py" in _render 
    197.   return self.nodelist.render(context) 

File "/Users/rohit.rawat/.virtualenvs/env/lib/python3.5/site-packages/django/template/base.py" in render 
    988.     bit = node.render_annotated(context) 

File "/Users/rohit.rawat/.virtualenvs/env/lib/python3.5/site-packages/django/template/base.py" in render_annotated 
    955.    return self.render(context) 

File "/Users/rohit.rawat/.virtualenvs/env/lib/python3.5/site-packages/django/template/loader_tags.py" in render 
    69.     result = block.nodelist.render(context) 

File "/Users/rohit.rawat/.virtualenvs/env/lib/python3.5/site-packages/django/template/base.py" in render 
    988.     bit = node.render_annotated(context) 

File "/Users/rohit.rawat/.virtualenvs/env/lib/python3.5/site-packages/django/template/base.py" in render_annotated 
    955.    return self.render(context) 

File "/Users/rohit.rawat/.virtualenvs/env/lib/python3.5/site-packages/django/template/loader_tags.py" in render 
    69.     result = block.nodelist.render(context) 

File "/Users/rohit.rawat/.virtualenvs/env/lib/python3.5/site-packages/django/template/base.py" in render 
    988.     bit = node.render_annotated(context) 

File "/Users/rohit.rawat/.virtualenvs/env/lib/python3.5/site-packages/django/template/base.py" in render_annotated 
    955.    return self.render(context) 

File "/Users/rohit.rawat/.virtualenvs/env/lib/python3.5/site-packages/django/template/loader_tags.py" in render 
    209.     return template.render(context) 

File "/Users/rohit.rawat/.virtualenvs/env/lib/python3.5/site-packages/django/template/base.py" in render 
    208.     return self._render(context) 

File "/Users/rohit.rawat/.virtualenvs/env/lib/python3.5/site-packages/django/template/base.py" in _render 
    197.   return self.nodelist.render(context) 

File "/Users/rohit.rawat/.virtualenvs/env/lib/python3.5/site-packages/django/template/base.py" in render 
    988.     bit = node.render_annotated(context) 

File "/Users/rohit.rawat/.virtualenvs/env/lib/python3.5/site-packages/django/template/base.py" in render_annotated 
    955.    return self.render(context) 

File "/Users/rohit.rawat/.virtualenvs/env/lib/python3.5/site-packages/django/template/defaulttags.py" in render 
    326.     return nodelist.render(context) 

File "/Users/rohit.rawat/.virtualenvs/env/lib/python3.5/site-packages/django/template/base.py" in render 
    988.     bit = node.render_annotated(context) 

File "/Users/rohit.rawat/.virtualenvs/env/lib/python3.5/site-packages/django/template/base.py" in render_annotated 
    955.    return self.render(context) 

File "/Users/rohit.rawat/.virtualenvs/env/lib/python3.5/site-packages/django/template/base.py" in render 
    1039.    output = self.filter_expression.resolve(context) 

File "/Users/rohit.rawat/.virtualenvs/env/lib/python3.5/site-packages/django/template/base.py" in resolve 
    726.      arg_vals.append(arg.resolve(context)) 

File "/Users/rohit.rawat/.virtualenvs/env/lib/python3.5/site-packages/django/template/base.py" in resolve 
    846.    value = self._resolve_lookup(context) 

File "/Users/rohit.rawat/.virtualenvs/env/lib/python3.5/site-packages/django/template/base.py" in _resolve_lookup 
    901.              (bit, current)) # missing attribute 

Exception Type: VariableDoesNotExist at/
Exception Value: Failed lookup for key [basket] in "<WSGIRequest: GET '/'>" 


Кроме того, если вы можете предложить более или менее подвержен ошибкам электронной коммерции рамки для Джанго, это было бы здорово!

ответ

2

У меня возникла эта проблема, потому что я использовал MIDDLEWARE вместо MIDDLEWARE_CLASSES в settings.py. Как только я изменил это, все сработало.

-1

Вам не хватает oscar.apps.basket.middleware.BasketMiddleware, в middleware настройка.

 Смежные вопросы

  • Нет связанных вопросов^_^