есть такой код:
from django.db import models class Author(models.Model): first_name = models.CharField(max_length=30) last_name = models.CharField(max_length=40) email = models.EmailField() class Book(models.Model): title = models.CharField(max_length=100) date = models.CharField(max_length=20) author = models.ForeignKey(Author)
когда ввожу коменду $ python manage.py makemigrations
то выдает вот такое:
You are trying to add a non-nullable field 'author' to book without a default; we can't do that (the database needs something to populate existing rows).
Please select a fix:
1) Provide a one-off default now (will be set on all existing rows)
2) Quit, and let me add a default in models.py
Select an option: 1
Please enter the default value now, as valid Python
The datetime and django.utils.timezone modules are available, so you can do e.g. timezone.now()