Answer the question
In order to leave comments, you need to log in
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()
print(Driver.objects.all())
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 questionAsk a Question
731 491 924 answers to any question