1👍
As you haven’t provided any details about the script, I’m assuming there is a function inside that takes the filename and a model name as parameters and does the work when invoked from the terminal. You can simply move that function to a controller and call it with both the parameters on request.
Django has a whole section in their documentation explaining how to do it.
1👍
From my experience you can do anything you would do on a regular python script inside a Django view. For example :
#! python3
# -*-coding:utf-8 -*
from django.shortcuts import HttpResponse
import os
def myView(request):
f = open('file.cvs', 'w')
f.write('Whatever you want')
f.close()
return HttpResponse('Done.')
You can put conditions and loops, so you should be able to put your entire script as a view like that.
- [Answered ]-Django haystack, no url in search results
- [Answered ]-Django Querying MongoDB ObjectIds in views from json object
- [Answered ]-Why do I get a "SSL error: called a function you should not call" with Django
Source:stackexchange.com