Ver Mensaje Individual
  #5 (permalink)  
Antiguo 27/05/2013, 12:44
josepbidegain
 
Fecha de Ingreso: enero-2013
Ubicación: Montevideo
Mensajes: 28
Antigüedad: 11 años, 3 meses
Puntos: 1
Respuesta: Jquery Ajax y django view

Gracias por tu respuesta, al final ya lo solucioné de la siguiente manera, en el html paso los parametros como una cadena de texto separando los valores por un string, ejemplo el @ y luego en la vista de django hago split para dejarlos en un array..

Código Python:
Ver original
  1. @csrf_exempt
  2. def filtrarNoticias(request):
  3.     copia = {}      
  4.     anio =  request.GET.get("anio")    
  5.     meses =  request.GET.get("meses")
  6.     tags = request.GET.get("tags")      
  7.      
  8.     mess =  meses.split("@")
  9.     tagss = tags.split("@")
  10.    
  11.     meses = []    
  12.     for m in mess:
  13.         meses.append(int(m))
  14.    
  15.     tags = []
  16.     for t in tagss:
  17.         tags.append(str(t))    
  18.        
  19.     nots = Noticia.objects.all()
  20.  
  21.     if ( anio != "" or anio != None ) and (anio != "0"):    
  22.         nots = Noticia.objects.filter( fecha__year = anio )  
  23.    
  24.    
  25.     entries = []
  26.     if ( len(meses) > 0 and meses[0] != "" and meses[0] != " " and meses[0] != None ):        
  27.         for f in nots:                      
  28.             if f.fecha.month in meses:                                
  29.                 entries.append(f)
  30.         nots = entries
  31.    
  32.     if ( len(tags) > 0 and tags[0] != "" and tags[0] != " " and tags[0] != None ):            
  33.         noticias  = []      
  34.         for n in nots:
  35.             for tag in n.tags.all():                
  36.                 if str(tag) in tags:                    
  37.                     noticias.append(n)            
  38.         nots = noticias      
  39.    
  40.     arr = []
  41.     for n in nots:        
  42.         fileName, fileExtension = os.path.splitext(str(n.img_noticia))
  43.         arch1 = fileName.replace("\\","/")+".190x135"+fileExtension
  44.         aux = {'titulo':str(n.titulo), 'img':str(arch1), 'copete': str(n.contenido[:100])}        
  45.         arr.append(aux)