Re: How to pass a string as url's parameter

2015-08-14 Thread Snezhana Spasova
You can do fruit = get_object_or_404(Fruit, name=fruit_name) but i wont recommend doing this with field that is not unique because it basically resolves to Fruit.objects.get(name=fruit_name) which will raise error if there are two objects with the same name... Furthermore you have choices..

Re: How to pass a string as url's parameter

2015-08-14 Thread Snezhana Spasova
If I understand the question correct.. you can do fruit = get_object_or_404(Fruit, name=fruit_name) even if its not SlugField. I dont recommend doing that with field that doesn't have unique=True because error will be raised if there are more than one objects with this name. (This equals