from django.db import models
# Create your models here.
class All(models.Model):
class Meta:
abstract = True
title = models.CharField(verbose_name='Заголовок', max_length=255, default='none')
def __str__(self):
return self.title
class Content(All):
class Meta:
abstract = True
counter = models.IntegerField(verbose_name='Счётчик', default=0)
class Video(Content):
fileurl = models.CharField(verbose_name='Url файла', max_length=255)
subtitresurl = models.CharField(verbose_name='Url субтитров', max_length=255)
class Meta:
verbose_name = 'Видео'
verbose_name_plural = 'Видео'
class Audio(Content):
bitrate = models.IntegerField(verbose_name='Битрейт', default=0)
class Meta:
verbose_name = 'Аудио'
verbose_name_plural = 'Аудио'
class Text(Content):
text = models.TextField(blank=True, verbose_name='Содержимое',)
class Meta:
verbose_name = 'Текст'
verbose_name_plural = 'Текст'
class Page(All):
text = models.ManyToManyField(Text, through='PageText', verbose_name='Текст', blank=True, related_name="page")
video = models.ManyToManyField(Video, through='PageVideo', verbose_name='Видео', blank=True, related_name="page")
audio = models.ManyToManyField(Audio, through='PageAudio', verbose_name='Аудио', blank=True, related_name="page")
class Meta:
verbose_name = 'Страница'
verbose_name_plural = 'Страница'
class PageText(models.Model):
text = models.ForeignKey(Text, on_delete=models.CASCADE)
page = models.ForeignKey(Page, on_delete=models.CASCADE)
quantity = models.IntegerField()
order = models.IntegerField()
class PageVideo(models.Model):
video = models.ForeignKey(Video, on_delete=models.CASCADE)
page = models.ForeignKey(Page, on_delete=models.CASCADE)
quantity = models.IntegerField()
order = models.IntegerField()
class PageAudio(models.Model):
audio = models.ForeignKey(Audio, on_delete=models.CASCADE)
page = models.ForeignKey(Page, on_delete=models.CASCADE)
quantity = models.IntegerField()
order = models.IntegerField()
Traceback (most recent call last):
web_1 | File "/usr/local/lib/python3.5/dist-packages/django/core/handlers/exception.py", line 34, in inner
web_1 | response = get_response(request)
web_1 | File "/usr/local/lib/python3.5/dist-packages/django/core/handlers/base.py", line 115, in _get_response
web_1 | response = self.process_exception_by_middleware(e, request)
web_1 | File "/usr/local/lib/python3.5/dist-packages/django/core/handlers/base.py", line 113, in _get_response
web_1 | response = wrapped_callback(request, *callback_args, **callback_kwargs)
web_1 | File "/usr/local/lib/python3.5/dist-packages/django/views/decorators/csrf.py", line 54, in wrapped_view
web_1 | return view_func(*args, **kwargs)
web_1 | File "/usr/local/lib/python3.5/dist-packages/django/views/generic/base.py", line 71, in view
web_1 | return self.dispatch(request, *args, **kwargs)
web_1 | File "/usr/local/lib/python3.5/dist-packages/rest_framework/views.py", line 505, in dispatch
web_1 | response = self.handle_exception(exc)
web_1 | File "/usr/local/lib/python3.5/dist-packages/rest_framework/views.py", line 465, in handle_exception
web_1 | self.raise_uncaught_exception(exc)
web_1 | File "/usr/local/lib/python3.5/dist-packages/rest_framework/views.py", line 476, in raise_uncaught_exception
web_1 | raise exc
web_1 | File "/usr/local/lib/python3.5/dist-packages/rest_framework/views.py", line 502, in dispatch
web_1 | response = handler(request, *args, **kwargs)
web_1 | File "/code/api/views.py", line 57, in get
web_1 | trasactiontaskfunc.delay(totrasaction)
web_1 | File "/usr/local/lib/python3.5/dist-packages/celery/app/task.py", line 427, in delay
web_1 | return self.apply_async(args, kwargs)
web_1 | File "/usr/local/lib/python3.5/dist-packages/celery/app/task.py", line 570, in apply_async
web_1 | **options
web_1 | File "/usr/local/lib/python3.5/dist-packages/celery/app/base.py", line 756, in send_task
web_1 | amqp.send_task_message(P, name, message, **options)
web_1 | File "/usr/local/lib/python3.5/dist-packages/celery/app/amqp.py", line 552, in send_task_message
web_1 | **properties
web_1 | File "/usr/local/lib/python3.5/dist-packages/kombu/messaging.py", line 169, in publish
web_1 | compression, headers)
web_1 | File "/usr/local/lib/python3.5/dist-packages/kombu/messaging.py", line 252, in _prepare
web_1 | body) = dumps(body, serializer=serializer)
web_1 | File "/usr/local/lib/python3.5/dist-packages/kombu/serialization.py", line 221, in dumps
web_1 | payload = encoder(data)
web_1 | File "/usr/lib/python3.5/contextlib.py", line 77, in __exit__
web_1 | self.gen.throw(type, value, traceback)
web_1 | File "/usr/local/lib/python3.5/dist-packages/kombu/serialization.py", line 54, in _reraise_errors
web_1 | reraise(wrapper, wrapper(exc), sys.exc_info()[2])
web_1 | File "/usr/local/lib/python3.5/dist-packages/vine/five.py", line 194, in reraise
web_1 | raise value.with_traceback(tb)
web_1 | File "/usr/local/lib/python3.5/dist-packages/kombu/serialization.py", line 50, in _reraise_errors
web_1 | yield
web_1 | File "/usr/local/lib/python3.5/dist-packages/kombu/serialization.py", line 221, in dumps
web_1 | payload = encoder(data)
web_1 | File "/usr/local/lib/python3.5/dist-packages/kombu/utils/json.py", line 70, in dumps
web_1 | **dict(default_kwargs, **kwargs))
web_1 | File "/usr/lib/python3.5/json/__init__.py", line 237, in dumps
web_1 | **kw).encode(obj)
web_1 | File "/usr/lib/python3.5/json/encoder.py", line 198, in encode
web_1 | chunks = self.iterencode(o, _one_shot=True)
web_1 | File "/usr/lib/python3.5/json/encoder.py", line 256, in iterencode
web_1 | return _iterencode(o, 0)
web_1 | File "/usr/local/lib/python3.5/dist-packages/kombu/utils/json.py", line 59, in default
web_1 | return super(JSONEncoder, self).default(o)
web_1 | File "/usr/lib/python3.5/json/encoder.py", line 179, in default
web_1 | raise TypeError(repr(o) + " is not JSON serializable")
web_1 | kombu.exceptions.EncodeError: <Audio: Audio1> is not JSON serializable
web_1 | [28/Sep/2019 11:17:56] "GET /api/page/1 HTTP/1.1" 500 237720
>>> from cryptography.hazmat import backends
>>> from cryptography.hazmat.primitives import serialization
private_key = serialization.load_der_private_key(pub_key_bytes, password=None, backend=default_backend())
Пожалуйста если будете удалять, удалите и аккаунт заодно... Найду другой сервис.