Retrieving URL Parameters in URLs

Like we said, we want to have a url of the form:

/post/<insert postID here>

The way we specify that <insert postID here> is with this:

(?P<postID>[a-zA-Z0-9_.-]+)

That's what's called a "regular expression." Basically it just does some intense string parsing to make sure it's an alphanumeric string and it will match that string to our postID argument.

Finally, we add the following in instaclone/urls.py:

url(r'^post/(?P<postID>[a-zA-Z0-9_.-]+)', View.as_view())

We still have to make the "View" and we'll retrieve the value there in the next section:

results matching ""

    No results matching ""