消息模块 urls.py 重定向



创建内容后收到以下警告。

File "C:btproductsurls.py", line 2, in <module>
from . import views
File "C:btproductsviews.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'),
]

你能帮忙吗?谢谢。

您使用的是什么 IDE?如果是旧的,请考虑切换到新的,并尝试习惯仅使用制表符(或仅空格(进行缩进。

最新更新