from django.views.generic import TemplateView, View from django.shortcuts import render from django.template.loader import render_to_string from django.core.files.base import ContentFile from work_sell.models import Picture from projects.models import Order from common.models import MainPage, PrintDocuments from users.models import ContractorResumeFiles from chat.models import Documents from work_sell.models import Picture class HomeTemplateView(View): template_name = 'home.html' def get(self, request, *args, **kwargs): main_settings = MainPage.objects.get(pk=1) return render(request, self.template_name, {'main_settings': main_settings}) class TestChatTemplateView(View): template_name = 'chat_test.html' def get(self, request, *args, **kwargs): test = [54,55,56] for pk in test: picture = Picture.objects.get(pk=pk) temp_file = ContentFile(picture.file.read()) temp_file.name = picture.file.name document = Documents() document.team_id = 1 document.order_id = 2 document.sender_id = 2 document.recipent_id = 4 document.file = temp_file document.save()