How to use django_autocomplete_light in django admin page?

32 Views Asked by At

I have a 2 model in django models

class Country(models.Model):
    country_name = models.CharField(max_length=30, null=False)
    country_phone_code = models.CharField(max_length=50, primary_key=True, null=False)
    country_image = models.CharField(max_length=255, blank=True)
    is_shipping_available = models.BooleanField(null=False)

class State(models.Model):
    id = models.AutoField(primary_key=True)
    state_name = models.CharField(max_length=30, null=False)
    country = models.ForeignKey(
        Country, on_delete=models.CASCADE, related_name="states"
    )
    is_shipping_available = models.BooleanField(null=False)

what i was trying to do register the states model in Modeladmin and have an auto field to select from country model since it is related using the foreign key relation ship and i found out that i can do it using the django_autocomplete_light ? help

0

There are 0 best solutions below