0

I get the following warning after creating content.

File "C:\bt\products\urls.py", line 2, in <module>
    from . import views
  File "C:\bt\products\views.py", line 29
    messages.success(request, 'Your profile was updated.')
                                                         ^
TabError: inconsistent use of tabs and spaces in indentation

views.py

def create(request):
    form = ProductForm(request.POST or None)
    if form.is_valid():
        form.save()
        messages.success(request, 'Your content was create.')
    context = { 'form': form }
    return render(request, "products/create.html", context)

urls.py

from django.urls import path
from . import views

urlpatterns = [
    path('', views.index, name='product-index'),
    path('create/', views.create, name='product-create'),
    path('<int:id>/', views.detail, name='detail'),
    #path('<int:product_id>/', views.productDelete, name='delete'),
]

Could you help? Thank you.

scout
  • 1
  • 1
  • 1
    Convert tabs into spaces. You have used both spaces and tabs for indentation. – John Strood Jun 21 '20 at 14:06
  • I fixed this, but it still gives errors. Thank u. – scout Jun 21 '20 at 14:20
  • 2
    Does this answer your question? ["inconsistent use of tabs and spaces in indentation"](https://stackoverflow.com/questions/5685406/inconsistent-use-of-tabs-and-spaces-in-indentation) – John Strood Jun 21 '20 at 14:22

1 Answers1

0

What IDE are you using? If its old, consider switching to a new one, and also try to habituate using only tabs (or only spaces) for indentation.