B
B
bituke2021-03-20 14:30:20
Django
bituke, 2021-03-20 14:30:20

Why does django convert it to another format when saving an object?

There is a tuple

CALL_SOURCE = (
  (0, 'неопределено'),
  (1, 'интернет'),
  (2, 'наружная реклама'),
  (3, 'рекомендация'),
  (4, 'циан'),
  (4, 'яндекс недвижимость'),
)


There is a model
class Client(models.Model):
  ''' Карточка клиента '''
        ....
  call_source = models.PositiveIntegerField(choices=CALL_SOURCE, blank=True, default=0)


When saving an object of this model, when I pass argument 0 to call_source, a number, of course, Django for some reason formats it in this format: 6055dc903e4a5977984061.png
WHY ?? WHY? I generally encounter this kind of thing. Already tried to pass the argument directly, it still converts it from a number to a tuple (0,) when saving.
How to fix this?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dr. Bacon, 2021-03-20
@bacon

You can tell us for a long time and beautifully how you are doing everything right there, but this will not work. Show your real code. And of course, you put a comma there.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question