GZ
Size: a a a
GZ
GZ
def validate_length(value,length=6):
if len(str(value))!=length:
raise ValidationError(u'%s is not the correct length' % value)
from
django.db import models
class MyModel(models.Model):
constraint_length_charField = models.CharField(validators=[validate_length])e
EM
GZ
GZ
GZ
GZ
GZ
GZ
GZ
GZ
reporter = models.ForeignKey(User, on_delete=models.CASCADE)То появилась ошибка:
django.db.utils.OperationalError: no such column: polls_trailer.reporter_idGZ
GZ
(venv) C:\Users\fedosacha02\Desktop\Project Site\mysite>python manage.py makemigrations polls
System check identified some issues:
WARNINGS:
polls.Trailer.pub_date: (fields.W161) Fixed default value provided.
HINT: It seems you set a fixed date / time / datetime value as default for this field. This may not be what you want. If you want to have the current da
te as default, use `django.utils.timezone.now`
polls.User.data_create_user: (fields.W161) Fixed default value provided.
HINT: It seems you set a fixed date / time / datetime value as default for this field. This may not be what you want. If you want to have the current da
te as default, use `django.utils.timezone.now`
You are trying to add a non-nullable field 'reporter' to trailer 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 with a null value for this column)
2) Quit, and let me add a default in models.py
Select an option: