0

I'm using redis version 6.2

This is the view which i'm working on:

elif request.method == 'POST':
    user_key = request.user
    bid_price = request.POST.get('bid')
    retrieve_product = request.POST.get('product.id')
    product_key = Product.objects.get(id=retrieve_product)
    minimum_price = product_key.base_price
    if float(bid_price) >= minimum_price:
        if redis_instance.hexists(product_key, "highest_bid"):
            hb_value = redis_instance.hget(product_key, "highest_bid")
        else:
            redis_instance.hset(product_key, "highest_bid", bid_price)
            hb_value = bid_price
        if bid_price > hb_value:
            redis_instance.hset(product_key, user_key, bid_price)  
            redis_instance.hset(product_key, "highest_bid", bid_price)
            messages.info('Your bid was successfully processed')
            return HttpResponse('successfully uploaded')
        else:
            return HttpResponse('Your bid is lower than current highest bid')

    else:
        return HttpResponse('Your bid is lower than minimum price')

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

This, instead, is the model:

class Product(models.Model):
    name = models.CharField(max_length=200, null=True)
    base_price = models.DecimalField(max_digits=5, decimal_places=2, null=True, blank=True)
    digital = models.BooleanField(default=False, null=True, blank=True)
    start_date = models.DateTimeField(default=timezone.now)
    end_date = models.DateTimeField(default=one_day_hence)
    bidding_finished = models.BooleanField(default=False)

    def __str__(self):
        return self.name

Error TraceBack :

Traceback (most recent call last):   File
"C:\Users\alber\AppData\Local\Programs\Python\Python38\lib\wsgiref\handlers.py",
line 138, in run
    self.finish_response()   File "C:\Users\alber\AppData\Local\Programs\Python\Python38\lib\wsgiref\handlers.py",
line 196, in finish_response
    self.close()   File "C:\Users\alber\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\servers\basehttp.py",
line 114, in close
    super().close()   File "C:\Users\alber\AppData\Local\Programs\Python\Python38\lib\wsgiref\simple_server.py",
line 38, in close
    SimpleHandler.close(self)   File "C:\Users\alber\AppData\Local\Programs\Python\Python38\lib\wsgiref\handlers.py",
line 335, in close
    self.result.close()   File "C:\Users\alber\AppData\Local\Programs\Python\Python38\lib\site-packages\django\http\response.py",
line 253, in close
    signals.request_finished.send(sender=self._handler_class)   File "C:\Users\alber\AppData\Local\Programs\Python\Python38\lib\site-packages\django\dispatch\dispatcher.py",
line 173, in send
    return [   File "C:\Users\alber\AppData\Local\Programs\Python\Python38\lib\site-packages\django\dispatch\dispatcher.py",
line 174, in <listcomp>
    (receiver, receiver(signal=self, sender=sender, **named))   File "C:\Users\alber\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\__init__.py",
line 57, in close_old_connections
    conn.close_if_unusable_or_obsolete()   File "C:\Users\alber\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\backends\base\base.py",
line 525, in close_if_unusable_or_obsolete
    self.close()   File "C:\Users\alber\AppData\Local\Programs\Python\Python38\lib\site-packages\django\utils\asyncio.py",
line 26, in inner
    return func(*args, **kwargs)   File "C:\Users\alber\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\backends\sqlite3\base.py",
line 261, in close
    if not self.is_in_memory_db():   File "C:\Users\alber\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\backends\sqlite3\base.py",
line 380, in is_in_memory_db
    return self.creation.is_in_memory_db(self.settings_dict['NAME'])   File
"C:\Users\alber\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\backends\sqlite3\creation.py",
line 12, in is_in_memory_db
    return database_name == ':memory:' or 'mode=memory' in database_name TypeError: argument of type 'WindowsPath' is not
iterable

During handling of the above exception, another exception occurred:

Traceback (most recent call last):   File
"C:\Users\alber\AppData\Local\Programs\Python\Python38\lib\socketserver.py",
line 650, in process_request_thread
    self.finish_request(request, client_address)   File "C:\Users\alber\AppData\Local\Programs\Python\Python38\lib\socketserver.py",
line 360, in finish_request
    self.RequestHandlerClass(request, client_address, self)   File "C:\Users\alber\AppData\Local\Programs\Python\Python38\lib\socketserver.py",
line 720, in __init__
    self.handle()   File "C:\Users\alber\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\servers\basehttp.py",
line 174, in handle
    self.handle_one_request()   File "C:\Users\alber\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\servers\basehttp.py",
line 197, in handle_one_request
    handler.run(self.server.get_app())   File "C:\Users\alber\AppData\Local\Programs\Python\Python38\lib\wsgiref\handlers.py",
line 145, in run
    self.handle_error()   File "C:\Users\alber\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\servers\basehttp.py",
line 119, in handle_error
    super().handle_error()   File "C:\Users\alber\AppData\Local\Programs\Python\Python38\lib\wsgiref\handlers.py",
line 382, in handle_error
    self.finish_response()   File "C:\Users\alber\AppData\Local\Programs\Python\Python38\lib\wsgiref\handlers.py",
line 184, in finish_response
    self.write(data)   File "C:\Users\alber\AppData\Local\Programs\Python\Python38\lib\wsgiref\handlers.py",
line 288, in write
    self.send_headers()   File "C:\Users\alber\AppData\Local\Programs\Python\Python38\lib\wsgiref\handlers.py",
line 345, in send_headers
    if not self.origin_server or self.client_is_modern():   File "C:\Users\alber\AppData\Local\Programs\Python\Python38\lib\wsgiref\handlers.py",
line 358, in client_is_modern
    return self.environ['SERVER_PROTOCOL'].upper() != 'HTTP/0.9' TypeError: 'NoneType' object is not subscriptable
3
  • Can you show the traceback of the error please. Commented Apr 19, 2021 at 18:21
  • Traceback added Commented Apr 19, 2021 at 18:54
  • 1
    This is a different error. Commented Apr 19, 2021 at 19:14

1 Answer 1

2

Based on the error message in your post title (not the traceback in the post), your issue is that you are calling the Redis.hexists(), Redis.hget() and Redis.hset() methods with the product_key variable, which contains a Product model object.

Instead, use a string value for the Redis key, such as str(product_key.id).

You need to do something similar for user_key as well.

Sign up to request clarification or add additional context in comments.

2 Comments

Already tried, it doesn't work. Give me back the same error
@Non_specificato That means you either didn't fix the issue correctly, or after you fixed it there was a second, different error.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.