N
N
Nyppy2020-02-03 20:49:28
Django
Nyppy, 2020-02-03 20:49:28

Why is django not storing data in the database?

I need to save data about the driver in the database, I get it from another source.
I do it like this

driver = Driver(user=profile)
driver.name='Name'
driver.surname='Surname'
driver.car='Name car'
driver.save()

And if in this function during its operation to display a list of all objects in the model, then they are there.
print(Driver.objects.all())

But when I want to get them by calling another function in the database, they are absent.
Why so?
Tell me please?)

Here is the model itself
class Driver(models.Model):
user = models.ForeignKey(Profile, on_delete=models.CASCADE)
name = models.CharField(max_length=32, verbose_name='Имя')
surname = models.CharField(max_length=32, verbose_name='Фамилия')
car = models.CharField(max_length=32, verbose_name='Машина')

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

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