Creating a unique slug
If you are going to be the only one posting, it is probably safe for you to add the date to your post. This wont work if you have two posts with the same title on the same day, which for a small site is unlikly.
In both cases, you will need to have CharField
rather than SlugField
as / is not a SlugField
safe character when using the Django admin.
/2009/01/30/the-slug.html
The second way, which you can also merge with the first add the id as the suffix.
/2009/01/30/1-the-slug.html
or
/1-the-slug.html
or perhaps
You may need to change your URL matching Regular Expression. The following matches everything up to a dot. This wont work unless you have a file extensions, you could just match to the end of the string.
'^hints\-and\-tips/(?P<slug>[^\.]+)\.html$'
Note: Setting a Primary field yourself means id probably won’t exist.