I have a model and I want to copy all of my data when copy function called and it make a copy of my books with new datetime I wrote this:
class Book(models.Model):
name = models.CharField(max_length=255)
created_date = models.DateTimeField(auto_now_add=True)
author = models.ForeignKey('Author', on_delete=models.CASCADE)
def copy(self):
new_book = Book()
new_book.name = self.name
new_book.created_date = models.DateTimeField(auto_now_add=True)
new_book.author = self.author
new_book.save()
class Author(models.Model):
name = models.CharField(max_length=255)
but author won't copied well