Django forgin key relation

class City(models.Model):
    name = models.CharField(max_length=100)

    def __str__(self):
        return self.name

class Country(models.Model):
    name = models.CharField(max_length=100)
    country = models.ForeignKey(City, on_delete=models.CASCADE)

    def __str__(self):
        return self.name

class Data(models.Model):
    name = models.CharField(max_length=100)

    def __str__(self):
        return self.name

I want in django admin every data have one city and one country but country must be have forgin key to city
Example
If city is Egypt country must be cairo or other country in egypt

I think, maybe you have mix up english words “country” and “city”. Egypt is a country and Cairo is a city in Egypt. So your models have to be something like:

class City(models.Model):
    name = models.CharField(max_length=100)
    country = models.ForeignKey(City, on_delete=models.CASCADE)

    def __str__(self):
        return self.name

class Country(models.Model):
    name = models.CharField(max_length=100)

    def __str__(self):
        return self.name

Every city belongs to one and only one country and many cities can be in the same country.

Create a forginkey for city inside city?

Sorry, my bad. I copy-pasted from your example and forgot to change the foreign key.

class City(models.Model):
    name = models.CharField(max_length=100)
    country = models.ForeignKey(Country, on_delete=models.CASCADE)

    def __str__(self):
        return self.name

class Country(models.Model):
    name = models.CharField(max_length=100)

    def __str__(self):
        return self.name