Advertisement
somecoder

'Cart' instance needs to have a primary key value

Aug 9th, 2022 (edited)
814
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 10.69 KB | None | 0 0
  1. Django Version: 4.1
  2. Python Version: 3.8.10
  3. Installed Applications:
  4. ('mezzanine.boot',
  5. 'django.contrib.auth',
  6. 'django.contrib.contenttypes',
  7. 'django.contrib.redirects',
  8. 'django.contrib.sessions',
  9. 'django.contrib.sites',
  10. 'django.contrib.sitemaps',
  11. 'django.contrib.messages',
  12. 'mezzanine.conf',
  13. 'mezzanine.core',
  14. 'mezzanine.generic',
  15. 'mezzanine.pages',
  16. 'cartridge.shop',
  17. 'mezzanine.blog',
  18. 'mezzanine.forms',
  19. 'mezzanine.galleries',
  20. 'filebrowser_safe',
  21. 'grappelli_safe',
  22. 'django.contrib.admin',
  23. 'django.contrib.staticfiles',
  24. 'django_comments')
  25. Installed Middleware:
  26. ('django.contrib.sessions.middleware.SessionMiddleware',
  27. 'django.middleware.common.CommonMiddleware',
  28. 'django.middleware.csrf.CsrfViewMiddleware',
  29. 'django.contrib.auth.middleware.AuthenticationMiddleware',
  30. 'django.contrib.messages.middleware.MessageMiddleware',
  31. 'django.middleware.clickjacking.XFrameOptionsMiddleware',
  32. 'cartridge.shop.middleware.ShopMiddleware',
  33. 'mezzanine.core.request.CurrentRequestMiddleware',
  34. 'mezzanine.core.middleware.RedirectFallbackMiddleware',
  35. 'mezzanine.core.middleware.AdminLoginInterfaceSelectorMiddleware',
  36. 'mezzanine.core.middleware.SitePermissionMiddleware',
  37. 'mezzanine.pages.middleware.PageMiddleware')
  38.  
  39. Template error:
  40. In template /home/vlad/anycoderu/cartridge/cartridge/shop/templates/shop/includes/user_panel.html, error at line 5
  41. 'Cart' instance needs to have a primary key value before this relationship can be used.
  42. 1 : {% load i18n shop_tags mezzanine_tags %}
  43. 2 : {% spaceless %}
  44. 3 : <a href="{% url "shop_cart" %}">
  45. 4 :
  46. 5 : {% blocktrans count request.cart.total_quantity as cart_quantity %} 1 item{% plural %}{{ cart_quantity }} items{% endblocktrans %}
  47. 6 : {% trans "in cart" %}:
  48. 7 : {{ request.cart.total_price|currency }}
  49.  
  50. 8 : {% if request.cart.total_quantity != 0 %}
  51. 9 : <a href="{% url "shop_checkout" %}" class="btn btn-primary">
  52. 10 : {% if request.session.order.step %}{% trans "Return to Checkout" %}{% else %}{% trans "Go to Checkout" %}{% endif %}
  53. 11 :
  54.  
  55. 12 : {% endif %}
  56. 13 : {% if settings.SHOP_USE_WISHLIST %}
  57. 14 : <a href="{% url "shop_wishlist" %}" class="btn-wishlist">
  58. 15 :
  59.  
  60. Traceback (most recent call last):
  61. File "/home/vlad/anycoderu/anycodenv/lib/python3.8/site-packages/Django-4.1-py3.8.egg/django/core/handlers/exception.py", line 55, in inner
  62. response = get_response(request)
  63. File "/home/vlad/anycoderu/anycodenv/lib/python3.8/site-packages/Django-4.1-py3.8.egg/django/core/handlers/base.py", line 220, in _get_response
  64. response = response.render()
  65. File "/home/vlad/anycoderu/anycodenv/lib/python3.8/site-packages/Django-4.1-py3.8.egg/django/template/response.py", line 114, in render
  66. self.content = self.rendered_content
  67. File "/home/vlad/anycoderu/anycodenv/lib/python3.8/site-packages/Django-4.1-py3.8.egg/django/template/response.py", line 92, in rendered_content
  68. return template.render(context, self._request)
  69. File "/home/vlad/anycoderu/anycodenv/lib/python3.8/site-packages/Django-4.1-py3.8.egg/django/template/backends/django.py", line 62, in render
  70. return self.template.render(context)
  71. File "/home/vlad/anycoderu/anycodenv/lib/python3.8/site-packages/Django-4.1-py3.8.egg/django/template/base.py", line 175, in render
  72. return self._render(context)
  73. File "/home/vlad/anycoderu/anycodenv/lib/python3.8/site-packages/Django-4.1-py3.8.egg/django/template/base.py", line 167, in _render
  74. return self.nodelist.render(context)
  75. File "/home/vlad/anycoderu/anycodenv/lib/python3.8/site-packages/Django-4.1-py3.8.egg/django/template/base.py", line 1005, in render
  76. return SafeString("".join([node.render_annotated(context) for node in self]))
  77. File "/home/vlad/anycoderu/anycodenv/lib/python3.8/site-packages/Django-4.1-py3.8.egg/django/template/base.py", line 1005, in
  78. return SafeString("".join([node.render_annotated(context) for node in self]))
  79. File "/home/vlad/anycoderu/anycodenv/lib/python3.8/site-packages/Django-4.1-py3.8.egg/django/template/base.py", line 966, in render_annotated
  80. return self.render(context)
  81. File "/home/vlad/anycoderu/anycodenv/lib/python3.8/site-packages/Django-4.1-py3.8.egg/django/template/loader_tags.py", line 157, in render
  82. return compiled_parent._render(context)
  83. File "/home/vlad/anycoderu/anycodenv/lib/python3.8/site-packages/Django-4.1-py3.8.egg/django/template/base.py", line 167, in _render
  84. return self.nodelist.render(context)
  85. File "/home/vlad/anycoderu/anycodenv/lib/python3.8/site-packages/Django-4.1-py3.8.egg/django/template/base.py", line 1005, in render
  86. return SafeString("".join([node.render_annotated(context) for node in self]))
  87. File "/home/vlad/anycoderu/anycodenv/lib/python3.8/site-packages/Django-4.1-py3.8.egg/django/template/base.py", line 1005, in
  88. return SafeString("".join([node.render_annotated(context) for node in self]))
  89. File "/home/vlad/anycoderu/anycodenv/lib/python3.8/site-packages/Django-4.1-py3.8.egg/django/template/base.py", line 966, in render_annotated
  90. return self.render(context)
  91. File "/home/vlad/anycoderu/anycodenv/lib/python3.8/site-packages/mezzanine/template/init.py", line 95, in render
  92. args = (self.nodelist.render(context), context, token)
  93. File "/home/vlad/anycoderu/anycodenv/lib/python3.8/site-packages/Django-4.1-py3.8.egg/django/template/base.py", line 1005, in render
  94. return SafeString("".join([node.render_annotated(context) for node in self]))
  95. File "/home/vlad/anycoderu/anycodenv/lib/python3.8/site-packages/Django-4.1-py3.8.egg/django/template/base.py", line 1005, in
  96. return SafeString("".join([node.render_annotated(context) for node in self]))
  97. File "/home/vlad/anycoderu/anycodenv/lib/python3.8/site-packages/Django-4.1-py3.8.egg/django/template/base.py", line 966, in render_annotated
  98. return self.render(context)
  99. File "/home/vlad/anycoderu/anycodenv/lib/python3.8/site-packages/Django-4.1-py3.8.egg/django/template/loader_tags.py", line 208, in render
  100. return template.render(context)
  101. File "/home/vlad/anycoderu/anycodenv/lib/python3.8/site-packages/Django-4.1-py3.8.egg/django/template/base.py", line 177, in render
  102. return self._render(context)
  103. File "/home/vlad/anycoderu/anycodenv/lib/python3.8/site-packages/Django-4.1-py3.8.egg/django/template/base.py", line 167, in _render
  104. return self.nodelist.render(context)
  105. File "/home/vlad/anycoderu/anycodenv/lib/python3.8/site-packages/Django-4.1-py3.8.egg/django/template/base.py", line 1005, in render
  106. return SafeString("".join([node.render_annotated(context) for node in self]))
  107. File "/home/vlad/anycoderu/anycodenv/lib/python3.8/site-packages/Django-4.1-py3.8.egg/django/template/base.py", line 1005, in
  108. return SafeString("".join([node.render_annotated(context) for node in self]))
  109. File "/home/vlad/anycoderu/anycodenv/lib/python3.8/site-packages/Django-4.1-py3.8.egg/django/template/base.py", line 966, in render_annotated
  110. return self.render(context)
  111. File "/home/vlad/anycoderu/anycodenv/lib/python3.8/site-packages/Django-4.1-py3.8.egg/django/template/defaulttags.py", line 322, in render
  112. return nodelist.render(context)
  113. File "/home/vlad/anycoderu/anycodenv/lib/python3.8/site-packages/Django-4.1-py3.8.egg/django/template/base.py", line 1005, in render
  114. return SafeString("".join([node.render_annotated(context) for node in self]))
  115. File "/home/vlad/anycoderu/anycodenv/lib/python3.8/site-packages/Django-4.1-py3.8.egg/django/template/base.py", line 1005, in
  116. return SafeString("".join([node.render_annotated(context) for node in self]))
  117. File "/home/vlad/anycoderu/anycodenv/lib/python3.8/site-packages/Django-4.1-py3.8.egg/django/template/base.py", line 966, in render_annotated
  118. return self.render(context)
  119. File "/home/vlad/anycoderu/anycodenv/lib/python3.8/site-packages/Django-4.1-py3.8.egg/django/template/loader_tags.py", line 208, in render
  120. return template.render(context)
  121. File "/home/vlad/anycoderu/anycodenv/lib/python3.8/site-packages/Django-4.1-py3.8.egg/django/template/base.py", line 177, in render
  122. return self._render(context)
  123. File "/home/vlad/anycoderu/anycodenv/lib/python3.8/site-packages/Django-4.1-py3.8.egg/django/template/base.py", line 167, in _render
  124. return self.nodelist.render(context)
  125. File "/home/vlad/anycoderu/anycodenv/lib/python3.8/site-packages/Django-4.1-py3.8.egg/django/template/base.py", line 1005, in render
  126. return SafeString("".join([node.render_annotated(context) for node in self]))
  127. File "/home/vlad/anycoderu/anycodenv/lib/python3.8/site-packages/Django-4.1-py3.8.egg/django/template/base.py", line 1005, in
  128. return SafeString("".join([node.render_annotated(context) for node in self]))
  129. File "/home/vlad/anycoderu/anycodenv/lib/python3.8/site-packages/Django-4.1-py3.8.egg/django/template/base.py", line 966, in render_annotated
  130. return self.render(context)
  131. File "/home/vlad/anycoderu/anycodenv/lib/python3.8/site-packages/Django-4.1-py3.8.egg/django/template/defaulttags.py", line 415, in render
  132. return strip_spaces_between_tags(self.nodelist.render(context).strip())
  133. File "/home/vlad/anycoderu/anycodenv/lib/python3.8/site-packages/Django-4.1-py3.8.egg/django/template/base.py", line 1005, in render
  134. return SafeString("".join([node.render_annotated(context) for node in self]))
  135. File "/home/vlad/anycoderu/anycodenv/lib/python3.8/site-packages/Django-4.1-py3.8.egg/django/template/base.py", line 1005, in
  136. return SafeString("".join([node.render_annotated(context) for node in self]))
  137. File "/home/vlad/anycoderu/anycodenv/lib/python3.8/site-packages/Django-4.1-py3.8.egg/django/template/base.py", line 966, in render_annotated
  138. return self.render(context)
  139. File "/home/vlad/anycoderu/anycodenv/lib/python3.8/site-packages/Django-4.1-py3.8.egg/django/templatetags/i18n.py", line 160, in render
  140. count = self.counter.resolve(context)
  141. File "/home/vlad/anycoderu/anycodenv/lib/python3.8/site-packages/Django-4.1-py3.8.egg/django/template/base.py", line 715, in resolve
  142. obj = self.var.resolve(context)
  143. File "/home/vlad/anycoderu/anycodenv/lib/python3.8/site-packages/Django-4.1-py3.8.egg/django/template/base.py", line 847, in resolve
  144. value = self._resolve_lookup(context)
  145. File "/home/vlad/anycoderu/anycodenv/lib/python3.8/site-packages/Django-4.1-py3.8.egg/django/template/base.py", line 914, in _resolve_lookup
  146. current = current()
  147. File "/home/vlad/anycoderu/cartridge/cartridge/shop/models.py", line 643, in total_quantity
  148. return sum(item.quantity for item in self)
  149. File "/home/vlad/anycoderu/cartridge/cartridge/shop/models.py", line 610, in iter
  150. self._cached_items = self.items.all()
  151. File "/home/vlad/anycoderu/anycodenv/lib/python3.8/site-packages/Django-4.1-py3.8.egg/django/db/models/fields/related_descriptors.py", line 596, in get
  152. instance_cache[key] = self.related_manager_cls(instance)
  153. File "/home/vlad/anycoderu/anycodenv/lib/python3.8/site-packages/Django-4.1-py3.8.egg/django/db/models/fields/related_descriptors.py", line 634, in init
  154. raise ValueError(
  155.  
  156. Exception Type: ValueError at /
  157. Exception Value: 'Cart' instance needs to have a primary key value before this relationship can be used.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement