Poetry with Poems inLoveLike

Poetic in Nature

EFT is Free SHA2-512 SHA3-512

Django_post_save_hook_to_create_a_relative_model_with_settings_and_a_sha2-sha512_key_and_code_to_be_used_as_signals.py_within_your_Django_3.2_LTS_app.

Author: Nathaniel Steven Henry Brown
Started: May 21, 2021
Last Edited: August 07, 2021
from django.db.models.signals import post_save
from django.conf import settings
from django.utils import timezone
from poems.models import Record, Relative, RecordParser
import hashlib

@receiver(post_save, sender=Record, dispatch_uid="record.record_relative_post_save")
def record_relative_post_save(sender, instance, created, **kwargs):
    try:
        relative = Relative(record=instance)
        record_parser = RecordParser(instance)
        relative.record_cache = record_parser.get_cache()
        relative.version = settings.EFT_CURRENT_VERSION
        relative.record = instance
        relative.key = hashlib.sha512(str(timezone.now()).encode('utf-8')).hexdigest()
        relative.save()
    except Exception as e:
        print('Record.record_relative_post_save - > Exception')
        print(e)
Characters: 825
Lines: 19
Words: 138

Views: 395

Changes Made

Revision #4
Title

1c1
< Django post_save hook to create a relative model with settings and a sha2-sha512 key and file to be used with signals.py within your Django app.<python><django><code><full><free>
---
> Django post_save hook to create a relative model with settings and a sha2-sha512 key and code to be used as signals.py within your Django 3.2 LTS app.<python><django><code><full><free>
Revision #3
Title

1c1
< Django post_save hook to create a record relative with settings and a sha512 key, To be saved as signals.py within your app.<python><django><code><full><free>
---
> Django post_save hook to create a relative model with settings and a sha2-sha512 key and file to be used with signals.py within your Django app.<python><django><code><full><free>
Revision #2
Body
4c4
< from poems.models import Eft, PoemEft
---
> from poems.models import Record, Relative, RecordParser
Revision #1
Body
10c10
< relative = Relative(poem=instance)
---
> relative = Relative(record=instance)