Skip to main content

A Django app to provide a WebcamPictureField, derived from FileField.

Project description

django-webcampicture

django-webcampicture is a very simple Django app that provides a specialization of Django's native ImageField: WebcamPictureField, which allows users to save images taken from their webcams, instead of uploading.

Quick start

  1. Install using pip:
pip install django-webcampicture
  1. Add "webcampicture" to your INSTALLED_APPS setting like this:
INSTALLED_APPS = [
    ...
    'webcampicture',
]
  1. Use the field in your models:
from django.db import models
from webcampicture.fields import WebcamPictureField


class Child(models.Model):
    name = models.CharField("Name", max_length=255)

    # WebcamPictureField takes the same parameters as ImageField,
    # besides the "width" and "height" positional parameters.
    picture = WebcamPictureField(
        "Picture", width=480, height=360, upload_to="pictures", blank=True
    )

    # Image URL example...
    @property
    def picture_url(self):
        if self.picture and hasattr(self.picture, "url"):
            return self.picture.url
  1. Remember to include in your templates:
{% load static %}
<link rel="stylesheet" href="{% static "webcampicture/css/webcampicture.css" %}">
<script src="{% static 'webcampicture/js/webcampicture.js' %}"></script>

Demo

demo

Settings and default values

WEBCAM_BASE64_PREFIX = "data:image/png;base64,"
WEBCAM_CONTENT_TYPE = "image/png"
WEBCAM_FILENAME_SUFFIX = ".png"

Overridable templates

webcampicture/webcampicture.html

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-webcampicture-0.1.9.tar.gz (6.2 kB view hashes)

Uploaded Source

Built Distribution

django_webcampicture-0.1.9-py3-none-any.whl (7.9 kB view hashes)

Uploaded Python 3

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