Answer the question
In order to leave comments, you need to log in
How to add a value to the base to the associated object?
Hello.
There are models
class Autor(models.Model):
first_name = models.CharField(max_length=100)
class Books(models.Model):
autor = models.ForeignKey(Autor)
title = models.CharField(max_length=100)
year = models.CharField(max_length=20)
Answer the question
In order to leave comments, you need to log in
book = Books(autor_id = id, title = 'title', year = '2017')
book.save()
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question