Encontré muchas preguntas/respuestas similares que sugerían usar "migrar" y "hacer migraciones", pero eso no funcionó. Estoy usando python 2.7 y pycharm 4.5.4 como IDE. cuando creé un nuevo modelo para el campo de imagen del producto, me registré en el administrador y ejecuté "makemigrations" y luego "migrar" y luego recibí este error OperationalError en /admin/products/productimage/ no existe tal tabla: products_productimage. Que me estoy perdiendo aqui ? A continuación es

modelo.py

    from django.db import models
    from django.core.urlresolvers import reverse
    from django.db.models.signals import post_save


    # Create your models here.

    class ProductQuerySet(models.query.QuerySet):
        def active(self):
            return self.filter(active=True)


    class ProductManager(models.Manager):
        def get_queryset(self):
            return ProductQuerySet(self.model, using=self.db)

        def all(self, *args, **kwargs):
            return self.get_queryset().active()


    class Product(models.Model):
        title = models.CharField(max_length=120)
        description = models.TextField(blank=True, null=True)
        price = models.DecimalField(decimal_places=2, max_digits=10)
        active = models.BooleanField(default=True)
        objects = ProductManager()

        def __unicode__(self):
            return self.title

        def get_absolute_url(self):
            return reverse("product_detail", kwargs={"pk": self.pk})
            # OR use this- return "/product/%s"%(self.pk)


    class Variation(models.Model):
        product = models.ForeignKey(Product)  ##this means each Variation is related to single product
        title = models.CharField(max_length=120)
        price = models.DecimalField(decimal_places=2, max_digits=10)
        sale_price = models.DecimalField(decimal_places=2, max_digits=10, null=True, blank=True)
        active = models.BooleanField(default=True)
        inventory = models.IntegerField(null=True, blank=True)  # default=-1 means unlimited

        def __unicode__(self):
            return self.title

        def get_price(self):
            if self.sale_price is not None:
                return self.sale_price
            else:
                return self.price

        def get_absolute_url(self):
            return self.product.get_absolute_url()


    # for post save receiver


    def product_saved_receiver(sender, instance, created, *args, **kwargs):
        # sender=modelclass, instance=actual instance being saved,created=boolean true if record was created
        product = instance
        variations = product.variation_set.all()
        if variations.count() == 0:
            new_var = Variation()
            new_var.product = product
            new_var.title = "Default"
            new_var.price = product.price
            new_var.save()


    post_save.connect(product_saved_receiver, sender=Product)


    # product image
    # you need to install python pillow library to support. it checks if file uploaded is actually an image and checks extension
    class ProductImage(models.Model):
        product = models.ForeignKey(Product)
        image = models.ImageField(upload_to='products/')

        def __unicode__(self):
            return self.product.title

el admin.py

    from django.contrib import admin
    from .models import Product, Variation, ProductImage

    # Register your models here.
    admin.site.register(Product)
    admin.site.register(Variation)
    admin.site.register(ProductImage)

Salida de hacer migraciones y migrar

[email protected] > makemigrations
    "C:\Program Files (x86)\JetBrains\PyCharm 4.5.4\bin\runnerw.exe" C:\Anaconda\python.exe "C:\Program Files (x86)\JetBrains\PyCharm 4.5.4\helpers\pycharm\django_manage.py" makemigrations C:/Users/user1/PycharmProjects/dj
    No changes detected

    Process finished with exit code 0
    [email protected] > migrate
    "C:\Program Files (x86)\JetBrains\PyCharm 4.5.4\bin\runnerw.exe" C:\Anaconda\python.exe "C:\Program Files (x86)\JetBrains\PyCharm 4.5.4\helpers\pycharm\django_manage.py" migrate C:/Users/user1/PycharmProjects/dj
    Operations to perform:
      Synchronize unmigrated apps: staticfiles, messages, crispy_forms
      Apply all migrations: sessions, admin, sites, auth, contenttypes, products, registration, newsletter
    Synchronizing apps without migrations:
      Creating tables...
        Running deferred SQL...
      Installing custom SQL...
    Running migrations:
      No migrations to apply.

    Process finished with exit code 0

en el navegador obtengo el siguiente erroringrese la descripción de la imagen aquí

respuesta

¿Lo intentaste migrate <yourapp> zero --fakey luego una vez más migrate <yourapp>? Esto funcionó para mí, tuve el mismo problema.

Si no le importa perder sus datos, puede eliminar el archivo SQLite3 y ejecutar los comandos 'makemigrations' y 'migrate' nuevamente. Probablemente también tendrá que volver a crear un superusuario (python manage.py createsuperuser)