Skip to main content

Instagram client for Django.

Project description

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.edge_media_to_caption.edges.0.node.text }}</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

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.

Project details


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.0.tar.gz (5.5 kB view details)

Uploaded Source

Built Distribution

django_easy_instagram-1.0.0-py3-none-any.whl (6.7 kB view details)

Uploaded Python 3

File details

Details for the file django-easy-instagram-1.0.0.tar.gz.

File metadata

  • Download URL: django-easy-instagram-1.0.0.tar.gz
  • Upload date:
  • Size: 5.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.4

File hashes

Hashes for django-easy-instagram-1.0.0.tar.gz
Algorithm Hash digest
SHA256 ae933f1fc2f80578f3085fe0bc251ef0273e26493da190b39ee1197679e16d57
MD5 8e142469b6de000e6d0f13eb6eac93c5
BLAKE2b-256 8dd94941c89e24de8887305bedef5a231acd523df8cca27e41b3575f0bb7f23c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for django_easy_instagram-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7712fdc65fc59ce5c80836b6c284f389c1488d8a45dbaa05ecdf074aa9860a2f
MD5 e3bc6e65c1d50810873d23abdf59cbcb
BLAKE2b-256 03c390841cedd35b68cdb952ca8b132c94aef4a0b45774c85d50c1816a786b50

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page