Python library for uploadcare
Pull request Compare This branch is 467 commits behind uploadcare:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

PyUploadcare: a Python module for Uploadcare

This consists in API interface for Uploadcare, and a couple of Django goodies.

To install it, just run

pip install pyuploadcare

(or easy_install pyuploadcare if you're into vintage)

How to use it with Django?

First of all, you'll need API keys: public and private. You can get them at the Uploadcare website.

As soon as you get your API keys, add them to your Django settings file:

    'pub_key': '***',
    'secret': '***',

If you don't want to use hosted assets (from you should add '' to INSTALLED_APPS setting and add


to django settings file. (Kudos to Sławek Ehlert for the feature!)

If you want to provide custom url for widget, you should add '' to INSTALLED_APPS setting and add


to django settings file.

Uploadcare widget will use default upload handler url, unless you specify PYUPLOADCARE_UPLOAD_BASE_URL django settings


You're all set now!

Adding a Uploadcare file field to your model is really simple. Like that:

from django.db import models

from import FileField

class Photo(models.Model):
    title = models.CharField(max_length=255)
    photo = FileField()

FileField doesn't require any arguments, file paths or whatever. It just works. That's the point of it all.

It looks nice in the admin interface

Admin page

Using it

It's really simple, just use your Uploadcare-enabled models as any other models:

for p in Photo.objects.all():

    # contains pyuploadcare.file.File object


    print, 400) # returns the url of resized version of the image
    print, 150)

Using it in templates

To make your life easier, Uploadcare file objects understand some 'magic' properties.

{{ }}
{{ }}
{{ }}
{{ }}

These are most useful in Django templates, which are somewhat limited in calling functions with arguments. Or you can contruct url manually:

{{ }}-/resize/400x300/-/effect/flip/-/effect/grayscale/

Time settings

Keep in mind that Uploadcare authentication will fail if computer clock is not synchronized.