W
W
WebDeveloper20162016-12-04 10:35:46
Django
WebDeveloper2016, 2016-12-04 10:35:46

Why does an error occur when loading fixtures?

The model is like this:

class Employee(models.Model):
    lastname = models.CharField('Фамилия', max_length=50)
    firstname = models.CharField('Имя', max_length=50)
    secondname = models.CharField('Отчество', max_length=50)
    birthdate = models.DateField('Дата рождения')
    email = models.EmailField('Электронная почта', max_length=50)
    phone = models.CharField('Телефон', max_length=15)
    begin_work = models.DateTimeField('Начало работы')
    end_work = models.DateTimeField('Окончание работы', blank=True, null=True, default=None)
    position = models.ForeignKey(Position)
    department = models.ForeignKey(Department)

I submit the fixture in the following format:
[
   {
      "model":"employees.Employee",
      "pk":1,
      "fields":{
         "lastname":"Мишин",
         "firstname":"Мирон",
         "secondname":"Аверьянович",
         "birthdate":"1977-01-30",
         "email":"[email protected]",
         "phone":"86-(257)552-2961",
         "begin_work":"2016-11-25 9:11",
         "end_work":"2016-11-25 17:39",
         "position_id":2,
         "department_id":1
      }
   }
]

Error when loading (loaddata): Could not load employees.Employee(pk=1): Error: value does not fit character varying(15). Why is this happening? What kind of "character varying(15)" type is this? Shouldn't pk be of type int? In addition, the docks show just such a pk format.
Python 3.5, Django 1.10

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
iegor, 2016-12-04
@WebDeveloper2016

Show logic. In your error it is written that it does not fit in a field of size 15. Maybe you have a field of size 15 where you shove something more than 15?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question