问题描述
我正在Heroku上设置应用程序.我的指示是这样的:
I'm setting app on Heroku. I do in instruction like so:
在错误1中,我在记事本中编写代码并在命令中运行它:
In error 1, I code in Notepad and run it in command:
import requests
from django.shortcuts import render
from django.http import HttpResponse
from .models import Greeting
# Create your views here.
def index(request):
r = requests.get('http://httpbin.org/status/418')
print(r.text)
return HttpResponse('<pre>' + r.text + '</pre>')
def db(request):
greeting = Greeting()
greeting.save()
greetings = Greeting.objects.all()
return render(request, 'db.html', {'greetings': greetings})
但是它不会像指令一样运行
But it dont run like instruction
我的命令出现了那,所以我不知道该怎么办.
My command appeard that so i dont know what can I should do.
我曾经尝试过堆栈帮助
推荐答案
我不确定您的问题是否仍然存在,但我现在也正在研究heroku,因此我为您提供了一个解决方案.fcntl模块是一个标准库,仅在Linux上可用!在您显然正在使用的Windows环境下,您将找不到它(提示:提到了记事本;)
I am not sure if your question is still on, but I'm digging into heroku right now, too and I have a solution for you.The fcntl module is a standard library available... on Linux only! You won't find it under Windows environment, which you are apparently using (hint: Notepad mentioned ;)
但是不用担心,只需遵循官方教程的上一课并调用本地heroku服务器,如:
But no worries, just follow the official tutorial's previous lesson and invoke the local heroku server like:
heroku local web -f Procfile.windows
这应该启动您的本地heroku服务器,没有问题,如下: http://localhost:5000
This should start your local heroku server no problem, under:http://localhost:5000
希望有帮助!
P.S.不要像这样单独运行views.py.该教程严格要求在虚拟环境下执行此操作,然后按计划进行.
P.S. Don't run views.py on its own like that. The tutorial strictly says to do it under the virtual environment, then it works, like planned.
这篇关于Heroku返回“导入错误:窗口上没有名为fcntl的模块".的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!