def novel_text(request, slug):
get_file = Novel.objects.get(slug=slug).novel_txt
file_path = os.path.join('media', str(get_file))
with open(file_path) as f:
lines = f.readlines()
novels = Novel.objects.get(slug=slug).title_rus
description = Novel.objects.get(slug=slug).description
paginator = Paginator(lines, 30)
page = request.GET.get('page')
plines = paginator.get_page(page)
context = {
'novels': novels,
'plines': plines,
'description': description,
}
return render(request, 'novels/text.html', context)
def function_based_view(request, param1, param2):
<логика>
return response
class ClassBasedView(View):
def dispatch(self, request, param1, param2):
<логика>
return response