我想将数据库中的某些内容上传到Google表格中。所以我想我将使用加工或多踩。选项很少,所以我决定像这样answer
进行处理我使用了处理模块,将其插入到视图和目录中,标题出现错误。
所以我非常肯定它必须在处理方面做一些事情。如果不处理,一切正常。
#sheet function that is used as proces
def sheet(uid,model):
gc = gspread.authorize(creds)
wks = gc.open("yelp")
all_entries = model.objects.filter(uid=uid)
worksheet = wks.get_worksheet(0)
counter = 0
for entry in all_entries:
print('working')
if counter < 100:
worksheet.append_row([ entry.name, entry.yurl,entry.categories,entry.rating,entry.review_count,entry.phone,entry.surl,entry.address,entry.city,entry.state])
counter = counter + 10
else:
time.sleep(100)
#view that calls it
def upload(request, uid):
p = Process(target=sheet, args=(uid, Result))
p.start()
print('process started')
return render(request, 'YelpGetter/status.html')
因此,我希望将数据库中的内容导入到Google电子表格中,但是出现错误:
[27/Jul/2019 20:23:00] "GET /latest HTTP/1.1" 200 7588 process started [27/Jul/2019 20:23:12] "GET /upload/610482019207 HTTP/1.1" 200 4430 Traceback (most recent call last): File "<string>", line 1, in <module> File "c:\users\mlade\appdata\local\programs\python\python37-32\Lib\multiprocessing\spawn.py", line 105, in spawn_main exitcode = _main(fd) File "c:\users\mlade\appdata\local\programs\python\python37-32\Lib\multiprocessing\spawn.py", line 115, in _main self = reduction.pickle.load(from_parent) File "C:\Users\mlade\Desktop\YelpGetter\views.py", line 7, in <module> from YelpGetter.models import Search, Result File "C:\Users\mlade\Desktop\YelpGetter\models.py", line 10, in <module> class Search(models.Model): File "C:\Users\mlade\Desktop\env\lib\site-packages\django\db\models\base.py", line 103, in __new__ app_config = apps.get_containing_app_config(module) File "C:\Users\mlade\Desktop\env\lib\site-packages\django\apps\registry.py", line 252, in get_containing_app_config self.check_apps_ready() File "C:\Users\mlade\Desktop\env\lib\site-packages\django\apps\registry.py", line 135, in check_apps_ready raise AppRegistryNotReady("Apps aren't loaded yet.") django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet.