models.py:
from djongo import models
class Passenger(models.Model):
_id = models.ObjectIdField()
first_name = models.CharField(max_length=100, blank=False, null=False)
last_name = models.CharField(max_length=100, blank=False, null=False)
class Bus(models.Model):
_id = models.ObjectIdField()
bus_driver = models.CharField(max_length=100, blank=False, null=False, unique=True)
passengers = models.ArrayField(model_container=Passenger)
admin.py:
from django.contrib import admin
# Register your models here.
from .models import Bus
@admin.register(Bus)
class BusAdmin(admin.ModelAdmin):
list_display = ('bus_driver',)
I would like in Django Admin to be able to add passengers to the bus. The bus can be without passengers too. How can I do it?
Currently, there is something wrong with the code that does not allow to do it: zero passengers, i.e. zero list is not allowed. Plus the add new passenger button does not exist, i.e. I can not add several passengers.