B
B
bituke2020-10-03 16:37:36
Django
bituke, 2020-10-03 16:37:36

How to autodetect model id in django?

There is a regular model in django

class Catalog(modles.Model):
  name_category = models.CharField('название категории', max_length=40)
  id_category = PositiveIntegerField()


id_category - This is the id of the created category, you need to make sure that this id calculates itself.
That is, I made the first category, id was assigned to it - 1
, created the second category - id 2 , the
third - id 3
, and so on according to the algorithm.
I promise feedback, thanks in advance for your help.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question