B
B
BEKa T2019-05-23 14:08:59
Django
BEKa T, 2019-05-23 14:08:59

How to save slugs by id?

How to make it so that, when saving a post, the slug is automatically generated by id?
For example:
Post 1:
slug = 1
Post 2:
slug = 2

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Egor Kazantsev, 2019-05-23
@saintbyte

Override the save method on the model, do save on the parent class and then do self.slug=self.pk then do save again.
absolutely correct and absolutely useless

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question