diff --git a/Pipfile b/Pipfile index 71f1faa..f4e1dce 100644 --- a/Pipfile +++ b/Pipfile @@ -36,6 +36,7 @@ psycopg2-binary = "*" hiredis = "*" twisted = {extras = ["http2", "tls"], version = "*"} whitenoise = "*" +django-picklefield = "*" [dev-packages] diff --git a/Pipfile.lock b/Pipfile.lock index 9c43460..82c30fd 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "af0051ce4cbe3965f9d19d33c2b4ce64f6fa9d4732a9e254979bade34c27664f" + "sha256": "97d73a69d57a13005810833cb3d8c3d066ab7a1c934731069061a622f0e3880a" }, "pipfile-spec": 6, "requires": { @@ -278,6 +278,14 @@ "index": "pypi", "version": "==0.1.6" }, + "django-picklefield": { + "hashes": [ + "sha256:15ccba592ca953b9edf9532e64640329cd47b136b7f8f10f2939caa5f9ce4287", + "sha256:3c702a54fde2d322fe5b2f39b8f78d9f655b8f77944ab26f703be6c0ed335a35" + ], + "index": "pypi", + "version": "==3.0.1" + }, "django-redis-cache": { "hashes": [ "sha256:9a2eebef421d996a82098a19d17ff6b321265cd73178fa398913019764e8394a" @@ -773,7 +781,7 @@ "sha256:407fa1e8eb3458d1b5614df51d9651a1180ea5fedf07feb46e45d7e25e6d6cdd", "sha256:d3a5ea5b350423f47d07639f74475afedad48cf41c0ad7a82ca13a3928af34f6" ], - "markers": "python_version >= '3.0'", + "markers": "python_version >= '3'", "version": "==2.2" }, "sqlparse": { diff --git a/feeds/migrations/0010_auto_20210312_0214.py b/feeds/migrations/0010_auto_20210312_0214.py new file mode 100644 index 0000000..e16dd45 --- /dev/null +++ b/feeds/migrations/0010_auto_20210312_0214.py @@ -0,0 +1,19 @@ +# Generated by Django 3.1.7 on 2021-03-11 23:14 + +from django.db import migrations +import picklefield.fields + + +class Migration(migrations.Migration): + + dependencies = [ + ('feeds', '0009_auto_20210312_0211'), + ] + + operations = [ + migrations.AlterField( + model_name='feed', + name='last_id', + field=picklefield.fields.PickledObjectField(blank=True, editable=False, null=True), + ), + ] diff --git a/feeds/models.py b/feeds/models.py index dcff7b3..73a76f3 100644 --- a/feeds/models.py +++ b/feeds/models.py @@ -4,6 +4,7 @@ from django.contrib.contenttypes.models import ContentType from django.core.cache import cache from django.db import models from django.utils import timezone +from picklefield import PickledObjectField from telebot import TeleBot from yamlfield.fields import YAMLField @@ -16,7 +17,7 @@ class Feed(models.Model): chat_id = models.CharField(max_length=33) check_interval = models.DurationField(help_text='in seconds') last_check = models.DateTimeField(null=True, blank=True) - last_id = models.JSONField(null=True, blank=True) + last_id = PickledObjectField(null=True, blank=True) config_type = models.ForeignKey(ContentType, on_delete=models.CASCADE) config_id = models.PositiveIntegerField()