Jahongir Rahmonov
Jahongir Rahmonov

Reputation: 13723

URL parameter in django

I have this code:

return redirect('shops:edit_shop', details['bio'])

basically it redirects to edit_shop view with one url parameter bio whose value is Testing Instagram API.

and this is my view:

def edit_shop_page(request, bio):
print bio
return render(request, 'shops/profile/edit_form.html')

To my surprise, that print bio part is printing only the first word, i.e the word Testing.

In short, I sent a parameter with value Testing Instagram API and received only Testing.

Why is it so? How can I fix this?

Relevant part of urls.py:

url(r'^edit-shop/(?P<bio>[\w_.]+)', edit_shop_page, name='edit_shop'),

Upvotes: 0

Views: 99

Answers (1)

bakkal
bakkal

Reputation: 55448

url(r'^edit-shop/(?P<bio>[\w_.]+)', edit_shop_page, name='edit_shop'),

Your regex will break the word after the first space, try allow a space too, e.g.

url(r'^edit-shop/(?P<bio>[\w ]+)', edit_shop_page, name='edit_shop'),

Upvotes: 2

Related Questions