I created a model in models.py and it is working but when I clicked on save button it is not saving

In admin pannel

here I created a color model but When Save button I am clicking on this save button it is not saving the color Models.py

class Color(models.Model):
    color = ColorField(default='#FF0000')

    class Meta:
        verbose_name_plural="colors"

    def __str__(self):
        return self.title
class Product(models.Model):
    pid=ShortUUIDField(length=10,max_length=100,prefix="prd",alphabet="abcdef")


    user=models.ForeignKey(CustomUser, on_delete=models.SET_NULL ,null=True)
    cagtegory=models.ForeignKey(Category, on_delete=models.SET_NULL ,null=True,related_name="category")
    vendor=models.ForeignKey(Vendor, on_delete=models.SET_NULL,null=True)
    color = ColorField(image_field="image")


    title=models.CharField(max_length=100,default="Apple")
    image=models.ImageField(upload_to=user_directory_path,default="product.jpg")
    description=models.TextField(null=True, blank=True,default="This is a product")

    price = models.DecimalField(max_digits=10, decimal_places=2, default=1.99)
    old_price = models.DecimalField(max_digits=10, decimal_places=2, default=2.99)

    specifications=models.TextField(null=True, blank=True)
    # tags=models.ForeignKey(Tags, on_delete=models.SET_NULL ,null=True)

    product_status=models.CharField(choices=STATUS, max_length=10,default="In_review")


    status=models.BooleanField(default=True)
    in_stock=models.BooleanField(default=True)
    featured=models.BooleanField(default=False)
    digital=models.BooleanField(default=False)

    sku=ShortUUIDField(length=10,max_length=100,prefix="sku",alphabet="abcdef")

    date=models.DateTimeField(auto_now_add=True)
    updated=models.DateTimeField(null=True,blank=True)

    class Meta:
        verbose_name_plural="Products"

    def product_image(self):
        return mark_safe('<img src="%s" width="50" height="50"/>'%(self.image.url))

    def __str__(self):
        return self.title
    def get_percentage(self):
        new_price=((self.old_price-self.price)/self.old_price)*100
        return new_price

see I created models In admin.py

class ProductAdmin(admin.ModelAdmin):
    inlines=[ProductImagesAdmin]
    list_display=['user','title','product_image','price','featured','product_status','color']
class ColorAdmin(admin.ModelAdmin):
    list_display=['color']
admin.site.register(Product,ProductAdmin)
admin.site.register(Color,ColorAdmin)

You can see that I created those models and registered it in admin.py. I also imported all necessary things.When I clicked on the save button and refresh the page it is not saving the colors. So how can I solve it?

Back to Top