Useful python-twitter template tags for use with python-twitter api in your django app
Switch branches/tags
Nothing to show
Clone or download
Latest commit 254882b Jan 17, 2016
Type Name Latest commit message Commit time
Failed to load latest commit information.
templatetags fix twitter tags Nov 12, 2014 Update Jan 18, 2016


Useful python-twitter template tags for use with python-twitter api in your django app. Inspired by django-twitter-tag app. The same type of template integration was desired with python-twitter.

This code is very compact and easily integrates into your existing projects. As of now, I am not planning to package it as a portable reusable app.

================ Documentation

It's pretty straight forward. See usage below.

================ Dependencies



================ Installation

Install this into one of your existing django projects simply by copying the 'templatetags' folder into one of your existing apps.

  1. Install python-twitter for your django project

  2. Copy the templatetags folder to the desired django app inside your project

  3. Ensure the appliation that you added the folder to is in your INSTALLED_APPS in your

  4. Use the tags inside of your template:

================ Usage

Example usage, assuming that tweets returns a user timeline (See Setting up your view on how to set this up).

<div class="block social-block social-twitter">
    {% load twitter_tags %}
    <h1>{% trans "Our Twitter" %}</h1>
        {% for tweet in tweets %}
            <div class="tweet-meta">
                <a href="{{ tweet.user.screen_name }}/status/{{ }}" target="_blank">
                    <img src="{{ tweet.user.profile_image_url }}" width="32" height="32" />
                    <h2>{{ }}<br /><span>@{{ tweet.user.screen_name }} &middot; {{ tweet.created_at|twitter_date }}</span></h2>
            <p>{{ tweet|expand_tweet_urls|urlize_tweet_text|safe }}</p>
        {% endfor %}

    <a href="#" class="btn btn-round btn-red">{% trans "Follow Us" %}</a>

NOTE: Make sure to use expand_tweet_urls before urlize_tweet_text

================ Setting up your View

Example get_tweets() function that can be used in your view to retrieve tweets.

import twitter
def get_tweets():
    returns twitter feed with settings as described below, contains all related twitter settings
    api = twitter.Api(consumer_key='yourcustomerkey',

    return api.GetUserTimeline(screen_name='twitter_screen_name', exclude_replies=True, include_rts=False)  # includes entities

Usage in your view:

from your.utils.lib import get_tweets
context['tweets'] = get_tweets()

================ Getting the code

The code is hosted at For python twitter, the code is hosted at