Resolved: Django model, how to auto-increment an object’s value

In this post, we will see how to resolve Django model, how to auto-increment an object’s value

Question:

So I have this Django model.py:
I would like the views attribute, to have an auto randomly generated number. So something like this:
and the views attribute will automatically take the value of the auto_views() function when creating a new product. In the same way as an auto-slug would work.

Best Answer:

You can specify a callable for the default:

If you have better answer, please add a comment about this, thank you!

Source: Stackoverflow.com