Пример #1
0
def test_exifgetter(key, expected):
    exif_data = {
        'Model': {'desc': 'Camera Model Name', 'val': 'DMC-GX7'},
        'Aperture': {'desc': 'Aperture', 'val': 1.7},
        'FileSize': {'desc': 'File Size', 'num': 4915200, 'val': '4.7 MB'},
    }

    assert getters.exifgetter(key)(exif_data) == expected
Пример #2
0
class Image(models.Model):
    image = models.ImageField()
    camera = models.CharField(
        editable=False,
        max_length=100,
    )
    exif = ExifField(
        source='image',
        denormalized_fields={'camera': exifgetter('Model')},
    )

    class Meta:
        app_label = 'tests'
Пример #3
0
class UploadedImage(models.Model):
    objects = None
    image = models.ImageField(upload_to="media", blank=True)
    camera = models.CharField(
        editable=False,
        max_length=100,
    )
    exif = ExifField(
        source='image',
        denormalized_fields={
            'camera': exifgetter('Model'),
        },
    )