0

In my application users names can contain chars like :

. @ - _

I want to make an API endpoint api/users/{username} but it's impossible with these chars in URL. How to bite this kind of problem?

2
  • What else can the username contain? Digits? Does it always start with a letter? Commented Jan 29, 2016 at 10:27
  • letters a-zA-Z and digits and must start with a letter Commented Jan 29, 2016 at 10:41

1 Answer 1

2

You need to use URL encoding for that and decode it in your view.

So "Username. @ - _" will be encoded as "Username.+%40+-+_".

To decode you can use urllib.unquote(url).decode('utf8').

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.