2009-07-29 48 views
0

首先即時通訊對不起,我的英語,即時新的Django,即時從php + codeigniter。Django和related_name

我有一個related_name一個問題,這些表都很好,但問題是,在選擇(下拉)的數據顯示是「壞」,以這樣的方式Tarifas_object:

HTML代碼:

<option value="1">Tarifas object</option> 

怎麼顯示正確的數據?

我的模型:

class Tarifas(models.Model): 
    recarga = models.CharField(max_length=7, help_text='Codigo de la tarifa') 
    precio = models.DecimalField(max_digits=7, decimal_places=2) 
    diligencias = models.PositiveIntegerField(max_length=3) 

    def __inicode__(self): 
     return self.precio 

    class Meta: 
     verbose_name_plural="Tarifas" 


class Recarga(models.Model): 
    socio = models.ForeignKey(User) 
    fecha = models.DateField(auto_now_add=True) 
    #valor = models.DecimalField(max_digits=6, decimal_places=2,verbose_name='Valor de la recarga', help_text= "Introduzca valores numericos ej.: 150.00") 
    valor = models.ForeignKey(Tarifas, related_name='recarga_valor') 
    diligencias = models.IntegerField(max_length=3, verbose_name='Cantidad de diligencias recargadas') 
    tiponcf = models.IntegerField(max_length=1,choices=TIPO_NCF, verbose_name='Tipo de comprobante fiscal') 
    ncf = models.CharField(max_length=19,verbose_name='Numero de comprobante fiscal') 
    cajero = models.CharField(max_length=20) 
    tipotarj = models.CharField(choices=TIPOS_TARJETAS, max_length=20, verbose_name='Tipo de tarjeta') 
    numtarj = models.IntegerField(max_length=16, verbose_name='Numero de tarjeta') 
    seguridad = models.IntegerField(max_length=3) 
    forma_pago = models.CharField(max_length=10, verbose_name='Forma de pago') 
    banco = models.CharField(max_length=20) 
    numerock = models.IntegerField(max_length=8, verbose_name='Numero de cheque') 

    def __unicode__(self): 
     return u'%s %s %s %s' % (self.socio,self.diligencias, self.fecha) 

    class Meta: 
     ordering = ['socio'] 

謝謝你們。

回答

2

如果這是從模型中直接複製並粘貼的,則您在Tarifas模型上拼寫爲unicode