How it works...

In this example, we are using a UUID field for the primary key of the Idea model. With this ID, each idea has an un-guessable unique URL. Alternatively, you can use slug fields for URLs, but then you have to make sure that each slug is populated and is unique throughout the website.

It is not recommended to use the default incremental IDs for URLs, for security reasons: users can figure out how many items you have in the database and try to access the next or previous item, although they might not have permission to do that.

In our example, we are using generic class-based views for the listing and reading ideas and function-based views for creating, updating, and deleting them. The views that change the records in the database require authenticated users with the @login_required decorator. It would be also perfectly fine to use class-based views or function-based views for all CRUDL functions.

After successfully adding or changing an idea, the user will be redirected to the detail view. After deleting an idea, the user will be redirected to the list view.