Tengo un error al ejecutar las pruebas de la unidad django, no he experimentado esto antes, y lo he estado buscando toda la tarde.Django Test Failing
estoy recibiendo este error en el terminal después de ejecutar Django prueba manage.py:
Error: Database test_unconvention couldn't be flushed. Possible reasons:
* The database isn't running or isn't configured correctly.
* At least one of the expected database tables doesn't exist.
* The SQL was invalid.
Hint: Look at the output of 'django-admin.py sqlflush'. That's the SQL this command wasn't able to run.
The full error: (1146, "Table 'test_unconvention.media_image' doesn't exist")
se hace referencia a la tabla media_images cuando se ejecuta sqlflush django-admin.py y genera bien cuando corro Django manage.py syncdb .
Este es el modelo de imagen que parece ser un problema:
from django.db import models
from django.contrib.contenttypes.models import ContentType
from django.contrib.contenttypes import generic
class Image(models.Model):
local_image = models.ImageField(upload_to="uploads/%Y/%m/%d/", height_field="height", width_field="width", max_length=255, null=True, blank=True)
remote_image = models.CharField(editable=False, max_length=255, null=True, blank=True)
thirdparty_page = models.CharField(editable=False, max_length=255, blank=True, null=True)
size = models.CharField(editable=False, max_length=25, blank=True, null=True)
content_type = models.ForeignKey(ContentType)
object_id = models.PositiveIntegerField()
content_object = generic.GenericForeignKey('content_type', 'object_id')
height = models.PositiveIntegerField(editable=False, blank=True, null=True)
width = models.PositiveIntegerField(editable=False, blank=True, null=True)
created_at = models.DateTimeField(editable=False, auto_now_add=True)
updated_at = models.DateTimeField(editable=False, auto_now=True)
def __unicode__(self):
if self.local_image:
return self.local_image.name
else:
return self.remote_image
Agradezco cualquier ayuda, por favor, hágamelo saber si debería proporcionar más información!
Así que el modelo de imagen vive en su aplicación 'media', sí? ¿Está definitivamente en tus aplicaciones instaladas para que el testrunner lo sincronice? –
La aplicación de medios está dentro de una aplicación/proyecto llamado 'común', que había agregado a mi installed_apps. Añadí 'common.media' a la lista y las pruebas funcionó, gracias :-) Si alguien más tiene un problema similar, vale la pena señalar que el syncdb y sqlall recogió la aplicación multimedia no hay problema, y solo el administrador .py prueba fallida. –
Cool. Me alegro de que esté ordenado –