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 details)

Uploaded Source

Built Distribution

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

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

Uploaded Python 3

File details

Details for the file django-webcampicture-0.1.9.tar.gz.

File metadata

  • Download URL: django-webcampicture-0.1.9.tar.gz
  • Upload date:
  • Size: 6.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.8 CPython/3.8.10 Linux/5.11.0-34-generic

File hashes

Hashes for django-webcampicture-0.1.9.tar.gz
Algorithm Hash digest
SHA256 cf3ed8acad7f9d112a06a7d58619bea510fbec414675ebd781a3f24bed30f497
MD5 098b665d49d15c646ddc6b61d8b801ed
BLAKE2b-256 8bb5e5fa9a776d88ba712a08b4c864bcf091c3757488dd26450773b08cd96174

See more details on using hashes here.

File details

Details for the file django_webcampicture-0.1.9-py3-none-any.whl.

File metadata

  • Download URL: django_webcampicture-0.1.9-py3-none-any.whl
  • Upload date:
  • Size: 7.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.8 CPython/3.8.10 Linux/5.11.0-34-generic

File hashes

Hashes for django_webcampicture-0.1.9-py3-none-any.whl
Algorithm Hash digest
SHA256 2e590c73af91b36cfd154c6175b2eccdae0a5450340af5d0dc3a1904103f2ee2
MD5 fbe891b4681aa36e2b3c92d88c767011
BLAKE2b-256 c1c55b645c448794e7f8619948adae9db0128cf93b32b7b4db516097ff25a1da

See more details on using hashes here.

Supported by

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