消息模块 urls.py 重定向[重复]

问题描述 投票:0回答:1

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

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

你能帮忙吗?谢谢你。

python django redirect message
1个回答
0
投票

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

© www.soinside.com 2019 - 2024. All rights reserved.