6👍
✅
You would need to put some restrictions on the value of the ‘name’ field only allowing [-A-Za-z]+, but you could do:
def my_request(request, name):
un_slugified_name = name.replace('-', '')
objects = MyModel.objects.get(name=unslugified_name)
However, the name you pass through the querystring would have to be exactly what’s in the database. YMMV. My advice, use a SlugField 🙂
2👍
Slugify is a Python function. To achieve your goal, Django would have to fetch the complete database (with at least the pk and the name
field), calculate the slug for each row and compare this to the given parameter. And this would be very imperformant, so:
TLDR: No
- [Django]-TemplateDoesNotExist in project folder django 1.8
- [Django]-Couldn't import Django error when I try to startapp
- [Django]-Why can’t Internet Explorer access my Django Development Server that’s accessible externally (i.e. not on localhost?)
Source:stackexchange.com