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.

Metadata

Release files for django-easy-instagram 1.0.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for django-easy-instagram 1.0.6
File Interpreter ABI Platform Actions
django_easy_instagram-1.0.6-py3-none-any.whl Python 3 none any Details for django_easy_instagram-1.0.6-py3-none-any.whl

Release files / django_easy_instagram-1.0.6-py3-none-any.whl

Download URL django_easy_instagram-1.0.6-py3-none-any.whl
Size 7.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
abe21e2cb9757e5e18ff915cf59bfed09c30236eec33cbdf1c8eb217d4f4f746
BLAKE2b-256 checksum
How to use checksums
df49e52786bd25c82326c320946bfa7e957041674d2e3fd5e8090c9902e7a269
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.6

Security for django-easy-instagram 1.0.6

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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