Django 1.11 ManyToMany

0

Save some people, I'm having trouble servicing an old system. I have a form via Django Admin where I manage some information, in it I added a ManyToMany relationship but the form is getting like this:

HereisthecodeI'musing:

models.py

classPalestraFile(models.Model):file=models.FileField(upload_to=path_and_rename('uploaded_files/palestra/'),blank=True,verbose_name="Arquivo da programação",
        help_text="(.pdf, .doc, .txt, .png, .jpg)")

class Palestra(Programacao):
    palestrante = models.ForeignKey(Palestrante,
                                    null=True,
                                    blank=True,
                                    limit_choices_to={'ativo': True})
    palestrantes = models.ManyToManyField(
        Palestrante,
        related_name='palestra_palestrantes',
        blank=True,
        limit_choices_to={'ativo': True}
    )
    file = models.ManyToManyField(
        PalestraFile, 
        related_name='palestra_palestrafiles', 
        blank=True, 
        verbose_name="Arquivos da palestra")

    class Meta:
        verbose_name = 'Palestra'
        verbose_name_plural = 'Palestras'

    def __str__(self):
        return '%s | %s ' % (date(self.dia, "d/m"), self.tema)

admin.py

from django.contrib import admin
from .models import Palestrante, Palestra, PalestraFile
from .forms import PalestranteFormAdmin

@admin.register(Palestrante)
class PalestranteAdmin(admin.ModelAdmin):
    form = PalestranteFormAdmin
    list_display = ['nome', 'email', 'slug', 'ativo']
    prepopulated_fields = {"slug": ("nome",)}
    # actions = ['compress_uploads']

    def compress_uploads(self, request, queryset):
        for obj in queryset:
            obj.save()
    compress_uploads.short_description = "Comprimir Imagens de Uploads"


@admin.register(Palestra)
class PalestraAdmin(admin.ModelAdmin):
    search_fields = (
        'tema',
        'palestrante__nome',
        'dia',
        'evento__nome',
        'evento__local'
    )
    list_display = [
        'evento',
        'palestrante',
        'dia',
        'tema',
        'sala',
        'horario_inicio',
        'horario_termino',
        'status'
    ]
    filter_horizontal = ['palestrantes']
    save_as = True

Would anyone know how to solve this ?? Many thanks for the help.

    
asked by anonymous 12.12.2018 / 00:37

0 answers