Skip to main content

django-easy-instagram

A Django application that provides a template tag for displaying content from a public Instagram profile. Has ability to cache files locally.

This was originally derived from Marco Pompili's version, but has now been largely rewritten.

Requirements

Installation

Install Django with your favourite Linux packaging system or you can use pip for installing python packages, if Django is not an official package for your distribution:

pip install django

Use pip to install Django Easy Instagram:

pip install django-easy-instagram

Pip should take care of the package dependencies for Django Easy Instagram.

Configuration

Add the application to INSTALLED_APPS:

  INSTALLED_APPS = (
    ...
    'sorl.thumbnail', # required for thumbnail support
    'django_easy_instagram',)

Rebuild your application database, this command depends on which version of Django you are using.

Run your migations:

python manage.py makemigrations django_easy_instagram
python manage.py migrate

Usage

You can use recent_media (containing 10-12 recent entries) like this:

<!DOCTYPE html>

{% load instagram_client %}

<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>{{ instagram_profile_name|capfirst }} Instagram feed</title>
</head>
<body>
<h1>{{ instagram_profile_name|capfirst }} Instagram Feed</h1>
<div id="django_recent_media_wall">
    {% instagram_user_recent_media instagram_profile_name %}
    {% for media in recent_media %}
        <div class="django_easy_instagram_media_wall_item">
            <a href="//instagram.com/p/{{ media.shortcode }}" target="_blank">
                <img src="{{ media.thumbnail_src }}"/>
                <span>{{ media.description }}</span>
            </a>
        </div>
    {% endfor %}
</div>
<p>Got from instagram</p>
</body>
</html>

Resizing and Caching Images

You are able to resize images, which will also mean they are cached locally rather than being loaded from Instagram's servers.

To enable this, ensure you have sorl.thumbnail in the INSTALLED_APPS, and that you have setup Django caching.

In order for requests to Instagram to work properly, you will need to ensure you set the sorl.thumbail setting:

THUMBNAIL_REMOVE_URL_ARGS = False

You can then use the local_cache template filter and specify a size:

{% for media in recent_media %}
...
<img src="{{ media.thumbnail_src|local_cache:'332x332' }}"/>
...
{% endfor %}

The images will be saved locally in a cache.

By default images will be resized and saved at 80% JPG quality, to override this you can use this setting in your Django settings file:

INSTAGRAM_CACHE_QUALITY = 90

Settings

  • INSTAGRAM_PROFILE - the Instagram username to fetch, used when no username is passed to the template tag
  • INSTAGRAM_UA - overrides the user agent sent in the request
  • INSTAGRAM_PROXY - provide a URL for an HTTP proxy

The library will automatically retry up to 3 times if it encounters a non-200 response.

Thanks

The original version of this was built by Marco Pompili available here - abandoned. I've sinced rewritten it to work with Instagram APIs rather than via scraping.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django_easy_instagram-1.0.4.tar.gz (6.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_easy_instagram-1.0.4-py3-none-any.whl (7.7 kB view details)

Uploaded Python 3

File details

Details for the file django_easy_instagram-1.0.4.tar.gz.

File metadata

  • Download URL: django_easy_instagram-1.0.4.tar.gz
  • Upload date:
  • Size: 6.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.14.6

File hashes

Hashes for django_easy_instagram-1.0.4.tar.gz
Algorithm Hash digest
SHA256 e241c2c183a598a8f7d70cc3e3109499218a54aac5d3e3c34d266fb263eeb48b
MD5 fc7b794b034d499f4634ef0f40e5a855
BLAKE2b-256 b285de13d80b51684e48b3fbc348367549dce1883ef57eb68401ce063b0402fd

See more details on using hashes here.

File details

Details for the file django_easy_instagram-1.0.4-py3-none-any.whl.

File metadata

File hashes

Hashes for django_easy_instagram-1.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 4118ae46835b3c55850da52485abcf4e652e2dbe6e3379b946e89274d9aa8e93
MD5 bd634e124c3665f3f48f010a9054a8c8
BLAKE2b-256 091d68778bd9e38f7e03d8d0c00486891caaeb3fe1bb74f89d99967c648dd1d2

See more details on using hashes here.

Release history Release notifications | RSS feed

1.0.6

1 file

1.0.5

1 file

This release

1.0.4 This release

2 files

1.0.3

1 file

1.0.2

1 file

1.0.1

2 files

1.0.0

2 files

0.3.4

1 file

0.3.3

1 file

0.3.2

1 file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page