O'Reilly logo

Learning Django Web Development by Ratan Kumar, Sanjeev Jaiswal

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating a tag page

Next, we will create a page that is similar to the Twitter listing for hashtags. For this task, we will almost follow the same architecture that we followed for the user profile. Let's start by adding a URL entry for the hashtag page. Open the urls.py file and insert the following entry (preferably below the user page entry so as to keep the table organized):

  url(r'^hashTag/(\w+)/$', HashTagCloud.as_view()),

The captured part of this regular expression is the same as that of the user page. We will only allow alphanumeric characters in a hashtag.

We will define the hashtag class in the controller as follows:

 class HashTagCloud(View): """Hash Tag page reachable from /hastag/<hashtag> URL""" def get(self, request, hashtag): params ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required