I have to sort the records that are loaded from the django administrator, by item-> brand-> model, but I sort by the id not by the name.
models.py
class ElementoModelo(models.Model):
elemento = models.ForeignKey(Elemento)
marca = models.ForeignKey(Marca)
modelo = models.CharField(max_length=50, unique=True)
class Meta:
ordering = ['elemento', 'marca', 'modelo']
def __str__(self):
return ("%s - %s - %s"%(self.elemento, self.marca, self.modelo )).strip() or "-"
admin.py
class ElementoModeloAdmin(admin.ModelAdmin):
list_display = ('elemento', 'marca', 'modelo',)
They could guide me Greetings