saziosu / book-swap

Code Institute: Project 4. Grade: Distinction
https://book-swap-13f900a2d9c7.herokuapp.com/
0 stars 1 forks source link

BUG: Slug Error when adding a book post with the same title #19

Closed saziosu closed 10 months ago

saziosu commented 10 months ago

Describe the bug Due to the slug being generated from the Book Title, there is an integrity error for the slug when a book with the same Title is added. There could be multiple posts with the same title because people could have the same book.

To Reproduce Steps to reproduce the behavior:

  1. Go to add-book
  2. Add a title the same as an existing post
  3. Fill out the rest of the form
  4. Hit submit button, see error

Expected behavior This should add a unique number to the slug to allow more than one post to have the same title

Screenshots

image
saziosu commented 10 months ago

Used autoslug to resolve this: https://django-autoslug.readthedocs.io/en/latest/ The url now gets a number added to the end of the slug if theres another post with the same slug