Answer the question
In order to leave comments, you need to log in
How to run a function in a django project from the console?
We need to execute the function. Since it is necessary to execute once to write url, view and form and display the button in the interface is superfluous. I want to execute in the console. I activate the shell in the console, go to the folder where the stata.py file is located with the following content:
from django.shortcuts import render
import json
from django.http import HttpResponse, HttpResponseRedirect
from .models import InstagramDemographicsAnalitics, Instagram,
def get_ida_instance():
for key, value in data.items():
profile = Instagram.objects.filter(userid= value['userId'])
if profile:
instagram = Instagram.objects.get(userid=value['userId'])
....
print('Create Success')
return HttpResponse('Create Success')
return render(request, 'ida.html')
if __name__ == '__main__':
get_ida_instance()
Answer the question
In order to leave comments, you need to log in
$ python manage.py shell
In [1]: from some_app.stata import get_ida_instance
In [2]: get_ida_instance()
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question