【发布时间】:2020-04-04 12:53:07
【问题描述】:
views.py
from django.shortcuts import render
from django.http import HttpResponse
from .models import *
def home(request):
return render(request, 'dashboard.html')
def products(request):
products=product.objects.all()
return render(request,'products.html', {'products':products})
def customer(request):
return render(request, 'customer.html')
错误:
from . import views
File "/Users/dileepkumar/Desktop/dj/accounts/views.py", line 12
return render(request,'products.html', {'products':products})
^
TabError: inconsistent use of tabs and spaces in indentation
【问题讨论】:
-
消息很清楚,您使用制表符和空格进行缩进。找到选项卡,然后用空格替换它们。
-
那么如何将第 12 行周围的制表符更改为空格,因为错误消息告诉您,因为 python 对缩进非常敏感