Get and show cookies for backend user model -- django

I want cookies to be displayed in the Admin User Model, the customer's data is located in the cookie section and when the customer login, Django requests a cookie from the user authentication account.

My Cookie name is 'device', I can use it for guest user but i don't know how to send it to backend and django ask me for it.

Error :

Field 'id' expected a number but got ''.

My Custom User Model:

class Account(AbstractBaseUser):
    phone_number = models.CharField(unique=True, max_length=11, validators=[MinLengthValidator(11)])
    device = models.CharField(max_length=200, blank=True)

    USERNAME_FIELD = 'phone_number'

models.py:

class Customer(models.Model):
    user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE, blank=True, null=True)
    # Get COOKIE For guest user -- I set a cookie as device
    device = models.CharField(max_length=200, blank=True)

views.py: Error comes from here

def Add_To_Cart(request, pk):
    if request.user.is_authenticated:
        """" Error comes from here, i have no idea how to call 
            cookie to user authentication backend."""
        customer = request.user.device <<--
        item = get_object_or_404(Post, pk=pk)
        order_item, created = OrderPost.objects.get_or_create(
            item=item,
            user=customer,
            ordered = False
        )
        order_qs = Order.objects.filter(user=customer, ordered=False)
        if order_qs.exists():
            order = order_qs[0]
            # check if the order post is in the order
            if order.items.filter(item__pk=item.pk).exists():
                order_item.qunatity += 1
                order_item.save()
                messages.info(request, "this item just added to your cart")
                return redirect('article-detail', pk=pk)
            else:
                order.items.add(order_item)
                messages.info(request, "this item just added to your cart")
                return redirect('article-detail', pk=pk)
        else:
            ordered_date = timezone.now()
            order = Order.objects.create(user=customer, ordered_date=ordered_date)
            order.items.add(order_item)
        messages.info(request, "this item just added to your cart")
        return redirect('article-detail', pk=pk)
    else:
        item = get_object_or_404(Post, pk=pk)

                # here i can create an account for guest user
        device = request.COOKIES['device'] <<--
        customer, created = Customer.objects.get_or_create(device=device)
        order_item, created = OrderPost.objects.get_or_create(
            item=item,
            user=customer,
            ordered = False
        )
        order_qs = Order.objects.filter(user=customer, ordered=False)
        if order_qs.exists():
            order = order_qs[0]
            # check if the order post is in the order
            if order.items.filter(item__pk=item.pk).exists():
                order_item.qunatity += 1
                order_item.save()
                messages.info(request, "this item just added to your cart")
                return redirect('article-detail', pk=pk)
            else:
                order.items.add(order_item)
                messages.info(request, "this item just added to your cart")
                return redirect('article-detail', pk=pk)
        else:
            ordered_date = timezone.now()
            order = Order.objects.create(user=customer, ordered_date=ordered_date)
            order.items.add(order_item)
        messages.info(request, "this item just added to your cart")
        return redirect('article-detail', pk=pk)
Back to Top