Hi I am having this error while I am trying to delete session and cart by IDs after order fulfillment.
carts/views.py class CheckoutFinalView(CartOrderMixin, View): > def post(self, request, *args, **kwargs): > order = self.get_order() > order_id = order.id > print order_id > > pay_method = request.POST.get("paymethod") > print pay_method > order.save() > > if request.POST.get('paymethod') == "CashOnDelivery": > order.mark_completed(order_id) > messages.success(request, "Thank you for your order") > del request.session["cart_id"] > del request.session["order_id"] > elif request.POST.get("paymethod") == 'CreditCard': > order.mark_completed(order_id) > messages.success(request, "Thank you for your order") > del request.session['order_id'] > del request.session['cart_id'] > else: > return redirect("order_detail", pk=order.pk) > In my orders/models.py: order_id = models.CharField(max_length=20, null=True, blank=True) paymethod = models.CharField(max_length=16, choices=CHOICES, default='CashOnDelivery') My orders/views.py: class CashOnDelivery(FormView): > model = Order > form_class = PaymentForm > template_name = 'orders/payment_method.html' > success_url = '/checkout/final' > > My orders/forms.py: class PaymentForm(forms.ModelForm): > class Meta: > model = Order > fields = [ > 'paymethod' > ] > My carts/checkout.html: {% extends 'base.html' %} > {% load crispy_forms_tags %} > {% block content %} > > <form method='POST' action="{% url 'checkout_final' %}">{% csrf_token %} > <!--<input type='hidden' name='payment_token' value='ABC' />--> > <!--if method selected then cod should not display--> > > {{ paymentform|crispy }} > > > <p><b><button type='submit'>Complete Order</button></b> > </p> > > </form> > {% endblock %}. > Finally my complete traceback: > Traceback: > File "C:\Users\Shazia\dd\lib\site-packages\django\core\handlers\base.py" in get_response > 132. response = wrapped_callback(request, *callback_args, **callback_kwargs) > File "C:\Users\Shazia\dd\lib\site-packages\django\views\generic\base.py" in view > 71. return self.dispatch(request, *args, **kwargs) > File "C:\Users\Shazia\dd\src\orders\views.py" in dispatch > 27. user_checkout = UserCheckout.objects.get(user=request.user) > File "C:\Users\Shazia\dd\lib\site-packages\django\db\models\manager.py" in manager_method > 127. return getattr(self.get_queryset(), name)(*args, **kwargs) > File "C:\Users\Shazia\dd\lib\site-packages\django\db\models\query.py" in get > 325. clone = self.filter(*args, **kwargs) > File "C:\Users\Shazia\dd\lib\site-packages\django\db\models\query.py" in filter > 679. return self._filter_or_exclude(False, *args, **kwargs) > File "C:\Users\Shazia\dd\lib\site-packages\django\db\models\query.py" in _filter_or_exclude > 697. clone.query.add_q(Q(*args, **kwargs)) > File "C:\Users\Shazia\dd\lib\site-packages\django\db\models\sql\query.py" in add_q > 1310. clause, require_inner = self._add_q(where_part, self.used_aliases) > File "C:\Users\Shazia\dd\lib\site-packages\django\db\models\sql\query.py" in _add_q > 1338. allow_joins=allow_joins, split_subq=split_subq, > File "C:\Users\Shazia\dd\lib\site-packages\django\db\models\sql\query.py" in build_filter > 1200. lookups, value) > File "C:\Users\Shazia\dd\lib\site-packages\django\db\models\fields\related.py" in get_lookup_constraint > 1745. lookup_class(target.get_col(alias, source), val), AND) > File "C:\Users\Shazia\dd\lib\site-packages\django\db\models\lookups.py" in __init__ > 101. self.rhs = self.get_prep_lookup() > File "C:\Users\Shazia\dd\lib\site-packages\django\db\models\lookups.py" in get_prep_lookup > 139. return self.lhs.output_field.get_prep_lookup(self.lookup_name, self.rhs) > File "C:\Users\Shazia\dd\lib\site-packages\django\db\models\fields\__init__.py" in get_prep_lookup > 727. return self.get_prep_value(value) > File "C:\Users\Shazia\dd\lib\site-packages\django\db\models\fields\__init__.py" in get_prep_value > 985. return int(value) > > Exception Type: TypeError at /orders/4/ > Exception Value: int() argument must be a string or a number, not 'SimpleLazyObject' -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAD83tOxhgfQGucutTQ%2BFScou0VORFJPhSXUnhFeiwqUD2TyETg%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.