GithubHelp home page GithubHelp logo

pombredanne / django-gravatar Goto Github PK

View Code? Open in Web Editor NEW

This project forked from chrisgilmerproj/django-gravatar

0.0 1.0 0.0 109 KB

Fork of http://code.google.com/p/django-gravatar (2010/10/22)

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

django-gravatar's Introduction

django-gravatar

image

django-gravatar makes it easy to add Gravatar support to your Django application through the addition of a template tag.

History

This code was taken from http://django-gravatar.googlecode.com, but it was superseded by the https://github.com/ericflo/django-avatar package, which provides a way more general approach to avatars in Django (not Gravatar-specific, with local Django caching).

If, however, you want to stick to a Gravatar-only solution, this package may a bit more "lightweight" and easier to start using.

Installation

To install it, use pip:

pip install django-gravatar

Usage

To use it with a Django installation, first place 'gravatar' in the INSTALLED_APPS tuple of your settings.py file like so:

INSTALLED_APPS = (
    # ...
    'gravatar',
)

Here is sample usage in a template:

{% load gravatar %}
{% gravatar_for_user request.user 40 g %}

In the previous example, a gravatar will be displayed for the specified user at a size of 40 pixels square with a rating of 'g'. The second and third arguments are optional and if not supplied the gravatar image will be 80 pixels square, the default gravatar image size, and will carry a rating of 'g', the default gravatar rating.

In addition to supplying a user object, you can also provide a username as a string. For instance:

{% gravatar_for_user 'jtauber' %}

Or by email:

{% gravatar_for_email '[email protected]' %}

It is possible to get the url wrapped in an html img tag:

{% gravatar_img_for_email '[email protected]' %}
{% gravatar_img_for_user request.user %}
{% gravatar_img_for_user 'jtauber' %}

If you only want the URL and not the full blown img`-tag, you can use the following functions:: {% gravatar_for_email '[email protected]' %} {% gravatar_for_user request.user %} {% gravatar_for_user 'jtauber' %} If you want the gravatar profile in json decoded format, you can use the following functions:: {% gravatar_profile_for_email '[email protected]' %} {% gravatar_profile_for_user request.user %} {% gravatar_profile_for_user 'jtauber' %} There are a few configuration variables available that you can use in your Django'ssettings.py: - **GRAVATAR_URL_PREFIX**: The gravatar URL to use. Default:'http://www.gravatar.com/'- **GRAVATAR_DEFAULT_IMAGE**: The default image to use. Default:''. See http://en.gravatar.com/site/implement/images/#default-image - **GRAVATAR_DEFAULT_RATING**: The default rating to use. Default:'g'. See http://en.gravatar.com/site/implement/images/#rating - **GRAVATAR_DEFAULT_SIZE**: The default size to use. Default:80. See http://en.gravatar.com/site/implement/images/#size - **GRAVATAR_IMG_CLASS**: The default CSS class name to add to generated<img>-tags. Default:'gravatar'``.

django-gravatar's People

Contributors

nvie avatar chrisgilmerproj avatar

Watchers

 avatar

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.