I am having problems passing variables with spaces to them through URLs. Now suppose I have an object
class Kiosks(models.Model): name = models.CharField(max_length = 200, unique = True) owner = models.ForeignKey(User)
Now the "name" entered for the kiosk is called "Akash Deshpande" and saved. Now, going to a new page in the views, I use the "kiosk name", that is.
messages.success(request,"Kiosk edited successfully") return HttpResponseRedirect('/kiosks/'+kiosk.name+'/')
The view that satisfies this URL is as follows:
def dashboard(request, kiosk_name): kiosk =Kiosks.objects.get(name__iexact = kiosk_name) deal_form = DealsForm(kiosk=kiosk) code_form = CodeForm() unverified_transactions = get_unverified_transactions(kiosk) return render(request,'kiosks/dashboard.html',{'kiosk':kiosk, 'deal_form' : deal_form, 'code_form' : code_form, 'unverified_transactions' : unverified_transactions})
The main urls.py just directs everything with the help of "kiosks" to pick up urls.py kiosks
urlpatterns = patterns('kiosks.views',url(r'^(\w+)/$', 'dashboard'),)
Now, instead of going to this page, the message "Page not found" is displayed. How to pass variables that have space? Is the question clear? Any help would be greatly appreciated.
Akamad007
source share