When I wanna add order in admin panel I see this Error [closed]
My model is :
class Order(models.Model):
id = ShortUUIDField(primary_key=True, unique=True, length=6, max_length=6, editable=False)
user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE, related_name='orders')
orderproducts = models.ManyToManyField(Product, through='OrderProduct')
total_amount = models.DecimalField(default=00.00, max_digits=10, decimal_places=2 ,blank=False) # final order price = total items quantity*total items price
order_date = models.DateTimeField(auto_now_add=True, auto_now=False)
finish = models.BooleanField(default=False, blank=True, null=True)
country = CountryField(blank_label="(select country)", multiple=False)
city = models.CharField(max_length=100, blank=False)
zip_code = models.CharField(max_length=100, blank=False)
state = models.CharField(max_length=100, blank=False)
street = models.CharField(max_length=100, blank=False)
phone_no = PhoneNumberField(null=True, blank=False)
and I get this error :
AttributeError at /admin/ecommerce/order/add/
'BlankChoiceIterator' object has no attribute 'len'
Request Method: GET
Request URL: http://127.0.0.1:8000/admin/ecommerce/order/add/
Django Version: 5.0.2
Exception Type: AttributeError
Exception Value:
'BlankChoiceIterator' object has no attribute 'len'
How can I fix this Error .
When I clicked add order in admin panel I get this Error . I cloned this code from github and I think it must work