Re: [novice question] Render a list of objects

2019-06-22 Thread Joe Reitman
The example code you provided will create a on the first iteration of the loop and tag every 4th iteration of the loop. This cycle will continue resulting in a table with 4 columns of data. Example: results = [ 1, 2, 3, 4, 5, 6, 7, 8 ] 1 2 3 4 5 6 7

Re: invalid literal for int() with base 10: ''

2019-06-22 Thread Amiya Dash
Can u send me the full project.share me the github link -- 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 thi

Re: invalid literal for int() with base 10: ''

2019-06-22 Thread Alejandro Pena
I feel you, figuring out such errors for the first time can be infinitely frustrating. I believe that the form is sending you product id numbers as strings, or 1 as ‘1’. If the product_id = ‘1’ then product_id is not None. However, you have defined product_id in the model for Product as an in

Re: invalid literal for int() with base 10: ''

2019-06-22 Thread Lutalo Bbosa joseph
kk will do that, On Sat, Jun 22, 2019 at 7:29 PM Amiya Dash wrote: > Can u send me the full project.share me the github link > > -- > 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

Re: invalid literal for int() with base 10: ''

2019-06-22 Thread Lutalo Bbosa joseph
This is what happens in the terminal when i use int(product_id) 2 2 [22/Jun/2019 16:56:33] "POST /carts/update/ HTTP/1.1" 302 0 [22/Jun/2019 16:56:33] "GET /carts/ HTTP/1.1" 200 8245 On Sat, Jun 22, 2019 at 7:50 PM Alejandro Pena wrote: > I feel you, figuring out such errors for the first tim

Re: invalid literal for int() with base 10: ''

2019-06-22 Thread Alejandro Pena
Sweet, looks like your code is working! You’re still seeing the ‘2’ and that the type of product_id is a string because your print statements are placed before you convert product_id into an int and then use it to search for product_obj. The evidence that it’s working is that it didn’t raise an

Re: invalid literal for int() with base 10: ''

2019-06-22 Thread Lutalo Bbosa joseph
but the remove function is supposed to work yet it returns the error but add works def update(request): product_id = request.POST.get("product_id") if product_id is not None : print(product_id) product_id = int(product_id) try: product_id = int(product_id)

Re: invalid literal for int() with base 10: ''

2019-06-22 Thread Alejandro Pena
Which error are you seeing now? Try making this change and let us know what the results are. cart_obj, new_obj = Cart.objects.get(user=request.user) if product_obj in cart_obj.products.all(): cart_obj.products.remove(product_obj) added = False Context: ht

Re: invalid literal for int() with base 10: ''

2019-06-22 Thread Lutalo Bbosa joseph
it all is not working, i guess i have to write another independent function for reomving products from the cart but thx. though i thought, it would workout On Sat, Jun 22, 2019 at 9:00 PM Alejandro Pena wrote: > Which error are you seeing now? Try making this change and let us know > what the re

Re: invalid literal for int() with base 10: ''

2019-06-22 Thread Alejandro Pena
Try this instead: cart_obj, new_obj = Cart.objects.get_or_create(user=request.user) You originally had: cart_obj, new_obj = Cart.objects.new_or_get(request) There is no .new_or_get method in the Django QuerySet API: https://docs.djangoproject.com/en/dev/ref/models/querysets/#get-or-create Als