Issue #44 new

ManyToManyField is not working

Anonymous created an issue

I have two Models. Model 2 (Bug) is ManyToManyField relationship with Model 1 (Test). For some reason if I try to add an existing Model 2 on a new Model 1, the dropdown box is not working. (See the attachement).

From the image, you can see the dropdown is not responsive if I want to add a new bug.

Is it an existing issue?

Comments (1)

  1. kalei-spirent

    Basically I can reproduce this issue with the follow simple relationship:

    #model.py
    from django.db import models
    from framework.models import TimestampModel
    
    class Passenger(TimestampModel):
        name = models.CharField(max_length=300)
    
    
    class Car(TimestampModel):
        name = models.CharField(max_length=200)
        owner = models.ManyToManyField(Passenger)
    
    class Seat(TimestampModel):
        name = models.CharField(max_length=200)
        belong = models.ManyToManyField(Car)
    
    #admin.py
    from django.contrib import admin
    from .models import Car, Passenger, Seat
    
    class SeatInline(admin.TabularInline):
        model = Seat.belong.through
        extra = 0
    
    class CarAdmin(admin.ModelAdmin):
        inlines = [
            SeatInline,
        ]
    
    admin.site.register(Car, CarAdmin)
    admin.site.register(Passenger)
    admin.site.register(Seat)
    

    If you go to add car page and try to add the new seat, the drop down will stop working (Even you have existing Seat object already). The drop down only work if you add a new seat entry and the page refresh.

  2. Log in to comment