一切都在我的本地计算机上运行,但是当我将项目上传到服务器时,我在第二条“ if”语句行收到此错误:
/ home /缩进中的制表符和空格的不一致使用
def scrape_weather(request):
if request.method == 'POST':
old_weather = Weather.objects.all()
old_weather.delete()
api_adress = "http://api.openweathermap.org/data/2.5/weather?q="
api_key = "***"
city = request.POST.get("city")
url = api_adress + city + api_key
if url == (api_adress + api_key):
url = api_adress + "warsaw" + api_key
json_data = requests.get(url).json()
new_weather = json_data['weather'][0]['main']
degree_kelvin = int(json_data['main']['temp'])
degree = degree_kelvin-273
pressure = json_data['main']['pressure']
new_weather = Weather()
new_weather.degree = degree
new_weather.pressure = pressure
new_weather.weather = new_weather
new_weather.save()
return redirect('/home/')
答案 0 :(得分:0)
好吧,我不得不编辑/etc/nanorc
文件:
set tabsize 4
set tabstospaces