In your base model write a function like this (if your description field is 
called 'name'):

    def __str__(self):
        return self.name

It works for me.
PS: Take care of python identation. I don't know if your tabulation is the 
same you paste here in forum but it placed wrongly could compromise your 
execution.

Good luck
Ezequias.

On Tuesday, September 10, 2019 at 1:30:28 PM UTC-3, Elmaco7 wrote:
>
> Hello, I do these models but the Django admin page doesn't read the "class 
> Meta" and " __str__".
> This is the models.py document
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> *from django.db import models# Create your models here.class 
> Autore(models.Model):    nome = models.CharField(max_length=50)    cognome 
> = models.CharField(max_length=50)def __str__(self):        return 
> self.autore_textclass Meta:    verbose_name_plural = "Autori"class 
> Genere(models.Model):    descrizione = models.CharField(max_length=30)def 
> __str__(self):        return self.genere_textclass Meta:    
> verbose_name_plural = "Generi"class Libro(models.Model):    titolo = 
> models.CharField(max_length=200)    autore = models.ForeignKey(Autore, 
> on_delete=models.CASCADE)    genere = models.ForeignKey(Genere, 
> on_delete=models.CASCADE)def __str__(self):        return 
> self.libro_textclass Meta:    verbose_name_plural = "Libri"*
>
>
> These are the results
>
>
>
>
> Can someone help me?
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/131b9bda-ba3c-4ebc-8471-c1fdabb8f5e5%40googlegroups.com.

Reply via email to