Skip to main content

This project integrates python-clamd with Django for easy scanning files for viruses on upload

Install

From PyPi with pip:

pip install django-clamd

or

easy_install django-clamd

You can also install development version direclty from GitHub:

pip install git+https://github.com/vstoykov/django-clamd.git

Aditioanlly if you want translations to work you need to add it to installed apps.

INSTALLED_APPS = (
    ...
    'django_clamd',
    ...
)

Additionally if you are using Ubuntu, in order for django-clamd to work install clamav-daemon.

sudo apt-get install clamav-daemon

Usage

You can use it in forms:

from django import forms
from django_clamd.validators import validate_file_infection

class UploadForm(forms.Form):
    upload_file = forms.FileField(validators=[validate_file_infection])

Or you can add it as validator directly in your model:

from django.db import models
from django_clamd.validators import validate_file_infection

class FileModel(models.Model):
    document = models.FileField(validators=[validate_file_infection])

You will have automatically scanning of upladed files in Django Admin and also when create ModelForm’s for that model.

Configuration

By default django-clamd tries to be smart and with good defaults. You can still configure how to connect to Clamd. Default values are:

CLAMD_SOCKET = '/var/run/clamav/clamd.ctl'
CLAMD_USE_TCP = False
CLAMD_TCP_SOCKET = 3310
CLAMD_TCP_ADDR = '127.0.0.1'

Note: When you are running on Fedora or CentOS and clamav-scanner package is installed then default value for CLAMD_SOCKET is:

CLAMD_SOCKET = '/var/run/clamd.scan/clamd.sock'

By default, this package will allow a file if ClamD cannot be contacted or if the scan fails. If you want validation to fail in these instances, change CLAMD_FAIL_BY_DEFAULT

CLAMD_FAIL_BY_DEFAULT = True

You also can disable virus scanning for development with:

CLAMD_ENABLED = False

Note: This is primary for make it easy to run a project on development without the need of installing Clamd on devlopment machine.

License

django-clamd is released as open-source software under the LGPL license.

Metadata

Release files for django-clamd 1.0.0

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

Source distribution (sdist)

Source distribution for django-clamd 1.0.0
File Size Uploaded
django_clamd-1.0.0.tar.gz 7.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-clamd 1.0.0
File Interpreter ABI Platform
django_clamd-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 17.3 kB

Release files / django_clamd-1.0.0.tar.gz

Download URL django_clamd-1.0.0.tar.gz
Size 7.6 kB
Tags Source
SHA-256 checksum
How to use checksums
106429a71db571b570c88493115891a5472623263d25ebe7f92bead6c2f04e81
BLAKE2b-256 checksum
How to use checksums
21a9b99c82906edb502eed580c1b8d93ce6efd540e48f7d5eb757921885c9b11
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.12.3

Release files / django_clamd-1.0.0-py3-none-any.whl

Download URL django_clamd-1.0.0-py3-none-any.whl
Size 9.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ee2d46ed535355aa0840f93dd8468bf9e2236e2a54ea2affa956e5c9326e328a
BLAKE2b-256 checksum
How to use checksums
994c369fc0bae4ba3da0fcfd41f5e43a6929b119d8d4211c7ae36ac5453706ec
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.12.3

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

0.4.0

2 release files

0.3.3

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

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