Automate unique slug (again)
This takes the "easier to ask forgiveness than permission" approach to making sure your model's slug is unique. If the model's slug is empty, make a slug from the model's 'name' field. We assume that it is a conflicting slug that is throwing the IntegrityError, in which case if the slug does not end with '-' followed by a number then append '-2'. If the slug does end with '-' followed by a number then capture that final number, increment it by one, save the new slug value and try savin g again.
- slug
- save