нет такой таблицы (makemigrations не фиксирует) - PullRequest
0 голосов
/ 26 марта 2020

Я получаю сообщение об ошибке в моей панели администратора. Я создал экземпляры PaintOption, но когда я открываю ProductModel, я получаю no such table: main_productmodel_paint_options. Я попытался запустить python manage.py makemigrations main и python manage.py migrate без удачи.

models.py

class PaintOption(models.Model):
    title = models.CharField(max_length=50)
    thumbnail = models.ImageField(upload_to='paint-options/')

    class Meta:
        verbose_name_plural = "Paint Options"

    def __str__(self):
        return self.title 


class ProductModel(models.Model): 
    def image_dir(self, filename):
        modeldir = slugify(self.title)
        return "models/" + osjoin(modeldir, filename)

    title = models.CharField(max_length=80)
    category = models.ManyToManyField(ProductCategory)
    featured_image = models.ImageField(upload_to=image_dir)
    paint_options = models.ManyToManyField(PaintOption)
    model_slug = AutoSlugField(null=True, default=None,
                         unique=True, populate_from='title')

    class Meta:
        verbose_name_plural = "Product Models"

    def __str__(self):
        return self.title

admin.py

class ProductModelAdmin(admin.ModelAdmin):
    ordering = ["title"]
    fieldsets = [
        ("Title/Featured Image", {'fields': ["title", "category", "featured_image", "image_tag", "featured"]}),     
        ("Paint Options", {'fields': ["paint_options"]}),       
    ]
...