Quando vou executar o makemigrations aparece este erro: <class 'escola.admin.Matriculas'>: (admin.E108) The value of 'list_display[1]' refers to 'aluno', which is not a callable, an attribute of 'Matriculas', or an attribute or method on 'escola.Matricula'.
Meu arquivo models.py:
from django.db import models
class Alunos(models.Model):
nome = models.CharField(max_length=30)
rg = models.CharField(max_length=9)
cpf = models.CharField(max_length=11)
data_nascimento = models.DateField()
def __str__(self):
return self.nome
class Curso(models.Model):
NIVEL = (
('B', 'Básico'),
('I', 'Intermediário'),
('A', 'Avançado')
)
codigo_curso = models.CharField(max_length=10)
descricao = models.CharField(max_length=100)
nivel = models.CharField(max_length=1, choices=NIVEL, blank=False, null=False, default='B')
def __str__(self):
return self.descricao
class Matricula(models.Model):
PERIODO = (
('M', 'Matutino'),
('V', 'Vespertino'),
('N', 'Noturno')
)
nome = models.ForeignKey(Alunos, on_delete=models.CASCADE)
curso = models.ForeignKey(Curso, on_delete=models.CASCADE)
periodo = models.CharField(max_length=1, choices=PERIODO, blank=False, null=False, default='M')
Meu arquivo admin.py:
from django.contrib import admin
from escola.models import Alunos, Curso, Matricula
class AlunosAdmin(admin.ModelAdmin):
list_display = ('id', 'nome', 'rg', 'cpf', 'data_nascimento')
list_display_links = ('id', 'nome')
search_fields = ('nome', )
list_per_page = 20
admin.site.register(Alunos, AlunosAdmin)
class Cursos(admin.ModelAdmin):
list_display = ('id', 'codigo_curso', 'descricao')
list_display_links = ('id', 'codigo_curso')
search_fields = ('codigo_curso', )
admin.site.register(Curso, Cursos)
class Matriculas(admin.ModelAdmin):
list_display = ('id', 'aluno', 'curso', 'periodo')
list_display_links = ('id', )
admin.site.register(Matricula, Matriculas)