0

` from django.db import models from .category import Category from multiselectfield import MultiSelectField

color_choices = ((1, 'red'),
                (2, 'Black'),
                (3, 'White'))


class Products(models.Model):
   image = models.ImageField(upload_to='uploads/product_images/', default='')
    category = models.ForeignKey(Category, on_delete=models.CASCADE, default=1)
    name = models.CharField(max_length=255, default="")
    price = models.FloatField(max_length=10, default=0)
    offer = models.CharField(max_length=30, default='')
    color = MultiSelectField(choices=color_choices, max_choices=3, max_length=3, 
 default=3)
    description = models.CharField(max_length=1052, default='')`

ERROR "ValueError: Field 'stock' expected a number but got 'UNAVAILABLE'." here I even removed the field 'stock ' from model but still getting error. It is not migrating..... What I do now? Please Help? models.py erroradmin.py

1 Answers1

0

The problem is from your original default being "unavailable" this cannot be used for an integer field.

You will need to delete the faulty migrations then update your model with the correct data type for the default e.g. 0 then run makemigrations and migrate

Sirwill98
  • 324
  • 1
  • 13