Field 'id' expected a number but got '9dzlzyftu9k5fi5ta8omk1mxgx1lyvhg'

It works fine until the form is created, but if i enter a value and click the Submit button, the following error code is displayed. The long string of the error code is cart_id. How can I change it? This is a simulated payment system that receives a cart with products and makes a payment.

Error MSG

class Cart(models.Model):
    cart_id = models.CharField(max_length=250, blank=True)
    customer = models.ForeignKey(User, on_delete=models.CASCADE)
    date_added = models.DateField(auto_now_add=True)
    class Meta:
        db_table = 'Cart'

    def __str__(self):
        return self.cart_id

class Payment(models.Model):
    cart = models.ForeignKey(Cart, on_delete=models.CASCADE)
    card_number = models.IntegerField()
    validity = models.IntegerField()
    cvc = models.IntegerField()
    card_password = models.IntegerField()

    def __str__(self):
        return '{0} {1}'.format(self.cart, self.card_number)

urlpatterns = [
    path('add/<int:pk>/', views.add_cart, name='add_cart'),
    path('', views.cart_detail, name='cart_detail'),
    path('remove/<int:pk>/', views.cart_remove, name='cart_remove'),
    path('full_remove/<int:pk>/', views.full_remove, name='full_remove'),
    path('payment_charge/', views.payment_charge, name='payment_charge'),

def _cart_id(request):
    cart = request.session.session_key
    if not cart:
        cart = request.session.create()
    return cart

def payment_charge(request):
    if request.method == "POST":
        form = PaymentForm(request.POST, request.FILES)
        if form.is_valid():
            post =
            post.cart_id = _cart_id(request)
            return redirect('cart:cart_detail')
        form = PaymentForm()
    context = {
        'form' : form
    return render(request, 'cart/payment_form.html', context)

class PaymentForm(forms.ModelForm):
    class Meta:
        model = Payment
        fields = ('card_number','validity','cvc','card_password')


<div class="mx-auto">
    <a href="{% url 'cart:payment_charge' %}" type="button"
        class="btn btn-outline-dark my_custom_button">
            Continue Shopping


<form action="" method="POST">
    {% csrf_token %}
    <input type="submit" value="제출">

Answers: 0