GithubHelp home page GithubHelp logo

aimeedonahue / django-bitly Goto Github PK

View Code? Open in Web Editor NEW

This project forked from discovery/django-bitly

0.0 2.0 0.0 240 KB

A Django app that manages bit.ly links to local objects.

License: BSD 3-Clause "New" or "Revised" License

django-bitly's Introduction

Django Bitly

Bit.ly integration for django

A Django app that supports automatic generation and tracking of bit.ly hashes for objects on the site. Will automatically track changes to URLs, and, if necessary, maintain redirects for moved objects.

Installation

$ pip install django-bitly

Add 'django_bitly' to your INSTALLED_APPS.

$ django-admin.py syncdb

Define the following settings:

BITLY_LOGIN
Your Bit.ly username
BITLY_API_KEY
Your Bit.ly API Key

Usage

Template Filters

{% load bitly %}

{{ myobject|bitlify }}
{{ myobject|clicks }}
{{ myobject|referrers }}
{{ myobject|referrer_chart:"250x100" }}

Available filters:

bitlify
Gets or create a short URL for the passed object. If unable to get and/or create from bit.ly, will just return the object's get_absolute_url value.
clicks
Returns the number of clicks that object has logged in bit.ly stats or fails silently.
referrers
Same as clicks filter but returns list of Referrer objects rather than number of clicks.
referrer_chart
Works like referrers, but returns the URL for a Google charts pie chart.

Models

You can use the bitlify manager method to create short urls for your model instances:

>>> from django_bitly.models import Bittle
>>> from myapp.models import MyModel

>>> myobj = MyModel.objects.get(pk=1)
>>> bittle = Bittle.objects.bitlify(myobj)
>>> bittle.shortUrl
'http://bit.ly/abcd1234'

Settings

BITLY_LOGIN
Your Bit.ly username. Required.
BITLY_API_KEY
Your Bit.ly API Key. Required.
BITLY_TIMEOUT
Timeout for the requests to Bit.ly, in seconds. Default: 5

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.