Skip to main content

A generic api for oauth2

Project description

Build Status Codecov

PyPi PyPI License

Project for merging different file types, as example easy thumbnail image and unpacking archive in one field

Installation

pip install django-snapshot-field

or from git

pip install -e git+https://githib.com/Apkawa/django-snapshot-field.git#egg=django-snapshot-field

Django and python version compatibles

Python
Django
3.7 3.8 3.9 3.10
2.2 :heavy_check_mark: :heavy_check_mark: :heavy_check_mark: :heavy_check_mark:
3.2 :heavy_check_mark: :heavy_check_mark: :heavy_check_mark: :heavy_check_mark:
4.0 :x: :heavy_check_mark: :heavy_check_mark: :heavy_check_mark:

Usage

from django.db import models
from snapshot_field.fields import SnapshotModelField

class Example(models.Model):
    name = models.CharField(max_length=20)

class ExampleReference(models.Model):
    name = models.CharField(max_length=20)
    ref = models.ForeignKey(Example)


class ExampleSnapshotModel(models.Model):
    snapshot = SnapshotModelField(null=True)
    snapshot_refs = SnapshotModelField(
        ['tests.Example', ['ExampleReference', {'fields': ['name', 'ref'], 'refs': ['ref']}]]
    )

    
obj = Example.objects.create(name='test_name')
obj_ref = ExampleReference.objects.create(name='refname', ref=obj)

snap = ExampleSnapshotModel.objects.create(snapshot=obj, snapshot_refs=obj_ref)

assert snap.snapshot.name == obj.name
assert snap.snapshot_refs.name == obj_ref.name
assert snap.snapshot_refs.ref.name == obj.name

obj.delete()
obj_ref.delete()
snap.refresh_from_db()

assert snap.snapshot.name == obj.name
assert snap.snapshot_refs.name == obj_ref.name
assert snap.snapshot_refs.ref.name == obj.name

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-snapshot-field-0.1.4.tar.gz (7.7 kB view hashes)

Uploaded Source

Built Distribution

django_snapshot_field-0.1.4-py2.py3-none-any.whl (8.6 kB view hashes)

Uploaded Python 2 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