Hi guys, first im so sorry with my english, im new with Django, im from php + codeigniter.
I have a problem with a related_name
, the tables are fine, but the problem is that in the Select (DropDown) the data display is "bad", in this way: Tarifas_object:
Html code:
<option value="1">Tarifas object</option>
how ill display the correct data?
my model:
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']
Thanks guys.