shane-mason / essential-generators

68 stars 8 forks source link

SUGGESTION: slug generation -> don't allow apostrophes, commas, etc. #4

Open jaradc opened 1 year ago

jaradc commented 1 year ago

Just a suggestion. I am using this package for generating dummy Django text. Because this package allows slugs like:

bas'-The-jorthe-of-val-lected
2005)-sethe-cat-mand-two8-onts
Egy.652369-pealti18-sq
in.-beis-ch

Django throws errors. Example error:

django.urls.exceptions.NoReverseMatch: Reverse for 'service_detail' with keyword arguments '{'username': 'admin', 'topic1': 'general', 'pk': 9, 'slug': "bas'-The-jorthe-of-val-lected"}' not found.

My knit-pick suggestion is to add argument to the slug generator to exclude punctuation and make it all lowercase. Simple for me to do but from a package-perspective, this could benefit your package and help more than just me. I don't know why anyone would want upper-case and punctuation in slugs but I'd argue that is not the most-common use-case.

shane-mason commented 1 year ago

This is a good suggestion - will update.