I would like to convert a user uploaded .docx file to .html using a function/method I have in models.py. I can do it with function based view with this kind of approach:
models.py:
class Article(models.Model):
main_file = models.FileField(upload_to="files")
slug = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
@classmethod
def convert_word(self, slug):
import pypandoc
pypandoc.convert_file('media/files/%s.docx' %slug, 'html', outputfile="media/files/%s.html" %slug)
And then I call the convert_word function like this in views.py:
def submission_conf_view(request, slug):
Article.convert_word(slug)
return redirect('submission:article_list')
What I would like to do is to call the same function/method but using Django's Class-based views, but I am having trouble figuring that out.