MongoDB error in Django Admin interface: "Select a valid choice. That choice is not one of the available choices."

Viewed 9

I am using Django with MongoDB with Djongo as the driver. I have the following two models:

from djongo import models
from djongo.models.fields import ObjectIdField, Field

# Create your models here.
class Propietario(models.Model):
    _id = ObjectIdField()
    Nombre = models.CharField(max_length=50)
    def __str__(self):
        return f"{self.Nombre}"

class Vehiculo(models.Model):
    _id = ObjectIdField()
    Propietario_Vehiculo = models.ForeignKey(Propietario, db_column='Propietario_Vehiculo', on_delete=models.CASCADE)
    Modelo = models.CharField(max_length=25)
    Capacidad = models.IntegerField()
    Cilindraje = models.IntegerField()
    Placa = models.CharField(max_length=6)
    SOAT_Fecha = models.DateField()
    Operacion_Fecha = models.DateField()

    def __str__(self):
        return f"{self.Modelo} de {self.Propietario_Vehiculo}"

Using the Django shell I am able to create and save Propietario objects and to link Vehiculo objects to their respecting owners using ForeignKey. However, any time I use the Django admin interface and input a Propietario to a new Vehicle, or try to save and existing one created with the Django shell, I get the error Select a valid choice. That choice is not one of the available choices. Any help would be greatly appreciated

0 Answers
Related