return an integer to a django model

hello django family,
I have a problem in my django model and I explain.
indeed I have a model like this

class valeurlabo(models.Model):
    Idvaleur=models.AutoField(primary_key=True)
    valeur=models.IntegerField(null=True)
    def __int__(self):
        return self.valeur

and

class pourcentageassurance(models.Model):
    Idpourcentage=models.AutoField(primary_key=True)
    pourcentage=models.FloatField(null=True)
    def __float__(self):
        return self.pourcentage
class labo(models.Model):
    Idlabo=models.AutoField(primary_key=True)
    patiente=models.ForeignKey(patient,null=True,on_delete=models.SET_NULL)
    examen=models.ForeignKey(examenlabo,null=True,on_delete=models.SET_NULL)
    valeur=models.ForeignKey(valeurlabo,null=True,on_delete=models.SET_NULL)
    pourcentage=models.ForeignKey(pourcentageassurance,null=True,on_delete=models.SET_NULL)
    def __str__(self):
        return self.examen

and I want him to return me an integer and a float and he returns me an object like this
pourcentageassurance objet (1)

I need someone to explain to me how to do it thanks.

Please clarify. What code is supposed to “return an integer and a float”?

class valeurlabo(models.Model):
    Idvaleur=models.AutoField(primary_key=True)
    valeur=models.IntegerField(null=True)
    def __int__(self):
        return self.valeur

and

class pourcentageassurance(models.Model):
    Idpourcentage=models.AutoField(primary_key=True)
    pourcentage=models.FloatField(null=True)
    def __float__(self):
        return self.pourcentage
so instead of the __str__ method
I used __float__ and __init__ since they are numbers

But those methods aren’t necessary.

When you’re trying to use those models, you can refer to the fields directly.

Example, if a_valeurlabo is an instance of valeurlabo, then a_valeurlabo.valeur is going to give you the integer value of that field.

So the question is where and how you’re using these models, not something within the model itself.

the class labo is an instance of the class percentageassurance and value labo
So she carries the key to percentagesurance and valuelabo

To be precise, and I understand we’re working across language translations issues, labo is not an instance of percentageassurance and valuelabo. It only contains references to them.

But these are just definitions of models.

You’re going to be using these models elsewhere, in views or other utility classes. It’s the code in those locations that is important, not the code here.

so in this case a question please

can we easily convert a whole character string?

You need to be a lot more specific here.

“Convert a whole character string” - What are you trying to convert and what are you trying to convert it to?

ok it’s good the solution to my problem has been found
thanks

I will come back after if there are others