so have model added user field foreign key user model
from django.db import models django.contrib.auth.models import user django.conf import settings class post(models.model): url = models.urlfield() title = models.charfield(max_length=140) user = models.foreignkey(settings.auth_user_model) than run
python3 manage.py makemigrations and get:
you trying add non-nullable field 'user' comment without default; can't (the database needs populate existing rows). please select fix: 1) provide one-off default (will set on existing rows) 2) quit, , let me add default in models.py i understand need give default user don't how that.
p.s. django version - 1.8.3
ok, happens migration utility's question hadn't appeared intuitive enough me. migration utility asking required fields of user model. need type in data 3 times (for username, password , email). problem utility isn't saying field expecting.
Comments
Post a Comment