Hello! I was building a gallery image, and everithing went fine with mysql, but lately, I changed my mind and I changed the database to postgres, it's the django recommendation. Well, sudenly I got this message: ProgrammingError?: ERROR: current transaction is aborted, commands ignored until end of transaction block
The problem is this insert: INSERT INTO galeria_album(nombre,path) VALUES('Galeria','media/ fotos/') and here is the model: class GaleriaManager( models.Manager ): def borrar_galeria( self ): from django.db import connection cursor = connection.cursor() try: cursor.execute( "TRUNCATE TABLE galeria_galeria" ) return True except: return False def borrar_album( self ): from django.db import connection cursor = connection.cursor() try: cursor.execute( "TRUNCATE TABLE galeria_album" ) return True except: return False def borrar_todo( self ): if self.borrar_album(): if self.borrar_galeria(): return True return False def cargar_galeria( self, path = 'media/fotos/', padre=0 ): import os import imghdr from django.db import connection cursorG = connection.cursor() cursorA = connection.cursor() list = {} #Creo el album raiz: root_gallery_name = 'Galeria' if padre == 0: ############ The next query breaks everything ################### cursorA.execute( "INSERT INTO galeria_album(nombre,path) VALUES('%s','%s')" % ( root_gallery_name , path ) ) connection.connection.rollback() padre= cursorA.lastrowid files = os.listdir( path ) for file in files: newpath = os.path.join( path, file ) if os.path.isdir( newpath ): cursorA.execute( "INSERT INTO galeria_album(padre_id,nombre,path) VALUES(%s,'%s','%s')" % ( padre, file, path ) ) list[file]= cursorA.lastrowid #print "Directorio %s " %(file), " listado: ",list self.cargar_galeria(newpath, list[file]) elif os.path.isfile( newpath ): if imghdr.what( newpath ): cursorG.execute( "INSERT INTO galeria_galeria(album_id,nombre,path,visible) VALUES(%s,'%s','%s',1)" % ( padre, file, newpath ) ) #print "Archivo: %s - Padre: %u \n" %( file, padre ) return True def reset_galeria( self ): self.borrar_todo() self.cargar_galeria() # Create your models here. class Album( models.Model ): padre = models.ForeignKey( 'self', 'id', blank=True,null=True ) nombre = models.CharField( maxlength=255 ) path = models.CharField( maxlength=255 ) imagen = models.ImageField(upload_to='albumes', null=True ) class Admin: pass def __str__(self): return self.nombre class Galeria( models.Model ): album = models.ForeignKey( 'Album', 'id', blank=True ) #padre = models.ForeignKey( 'self', 'id', blank=True ) nombre = models.CharField( maxlength=255 ) path = models.CharField( maxlength=200 ) visible = models.BooleanField( default=True ) objects = GaleriaManager() def __str__( self ): return self.nombre class Admin: list_display = ( 'nombre', 'visible' ) I found this information: http://code.djangoproject.com/ticket/852 but it didn't help me. I'm testing it in the shell: >>> from mysite.galeria.models import Galeria >>> Galeria.objects.reset_galeria() I was excited because my first django site is almost ready for production and suddenly... it failed :-( Could anybody help me please? Thank you very much. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to [EMAIL PROTECTED] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---