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

Uploaded Source

Built Distribution

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

Uploaded Python 2 Python 3

File details

Details for the file django-snapshot-field-0.1.4.tar.gz.

File metadata

  • Download URL: django-snapshot-field-0.1.4.tar.gz
  • Upload date:
  • Size: 7.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.10

File hashes

Hashes for django-snapshot-field-0.1.4.tar.gz
Algorithm Hash digest
SHA256 6dee5c17e087b22f01c0009a02073c165f2a928819b3d95166fb1c310c98bdf4
MD5 cdad7d3b07cf74c963b6e92daee1ec0c
BLAKE2b-256 bf3d74eb9158c9388d791c10a409faa11cd1096324a76447edc2effa50f0de15

See more details on using hashes here.

File details

Details for the file django_snapshot_field-0.1.4-py2.py3-none-any.whl.

File metadata

  • Download URL: django_snapshot_field-0.1.4-py2.py3-none-any.whl
  • Upload date:
  • Size: 8.6 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.10

File hashes

Hashes for django_snapshot_field-0.1.4-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 3860267064cf87c376068f0b32ba921740bb8274dfbcc43af75c399f9a03ca8a
MD5 adf4823bde36905a3903a2db6cd890df
BLAKE2b-256 e9d2f2c23a2d21e80db5406ecc23aff198c647c5aa3eeabdbad34664cc9f7fe0

See more details on using hashes here.

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