-2

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')

The error:

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
khelwood
  • 55,782
  • 14
  • 81
  • 108
deep123
  • 15
  • 3
  • 1
    The message is clear, you used both tabs and spaces for indenting. Find the tabs, and replace them with spaces. – Thierry Lathuille Apr 04 '20 at 12:55
  • Well how about changing the tabs around the twelfth line to spaces as the error message tells you, as python is quite sensitive to indenting – Eric Apr 04 '20 at 12:55

1 Answers1

0

My suggestion would be to use any Text Editor such as VSCode, or Atom, and use the builtin feature "Convert indentation to Spaces".

These text editors also allow you to use tab for indentation while automatically inserting the required amount of spaces in that place for you, among a dozen other reasons why to use a text editor for programming.

Tushar Sadhwani
  • 414
  • 4
  • 7