E
E
EgorLetov2019-11-07 23:01:26
Django
EgorLetov, 2019-11-07 23:01:26

Django how to solve form problem?

I have two models

class City(models.Model):
    name = models.CharField('City', max_length=50)
    temperature = models.ForeignKey('Temperature', blank=True, null=True, on_delete=models.CASCADE)

    def __str__(self):
        return self.name

    class Meta:
        verbose_name_plural = 'Cities'


class Temperature(models.Model):
    temperature = models.IntegerField('Temperature')

    def __str__(self):
        return str(self.temperature)

There is a form in which you need to display all cities from the database and show their temperature, but it doesn’t work, how to implement it?
How can cities from the database be entered into the form or is it impossible, but can it be somehow different?
Like in Choices or what?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question