我有一个 Django 应用程序,我正在向它添加 Django 日志对象,我遵循此文档 https://code.osuosl.org/projects/django-object-log/wiki/Usage#Registering-Action-Types
我在文档中添加日志条目的一部分,该文档给出了如何在 def 方法中添加日志的以下示例,这是示例:
# store log_action for faster access
log = LogItem.objects.log_action
def my_view(request, pk):
""" example view that retrieves an object by its pk """
obj = SomeModel.objects.get(pk=pk)
log('MY_EVENT', request.user, obj)
tasks.py 是我的应用程序中的一个视图,这是我要添加日志调用的定义
def edit_task(request, task_id):
t = get_object_or_404(Task, pk=task_id)
t.category = request.POST['cat_dd']
t.subcategory = request.POST['subcat_dd']
t.name = request.POST['task_name']
t.description = request.POST['task_desc']
t.country = request.POST['country_dd']
t.city = request.POST['task_city']
t.address = request.POST['task_address']
t.status = request.POST['status_dd']
log('MY_EVENT', request.user, t)
if (employer_id == NULL or getcategory == "Please select a category" or getsubcategory == "Please select a subcategory" or getname == "" or getdesc == "Write a short description about your task.." or getcountry == "(please select a country)" or getcity == "" or getaddress == "" or getstatus == ""):
return render_to_response('editTask.html',RequestContext(request))
else:
t = Task.objects.create(employer = employer_id, category = getcategory, subcategory = getsubcategory, name = getname, description = getdesc, country = getcountry, city = getcity, address = getaddress, status = getstatus, contractor = NULL)
t.save()
return render_to_response('task.html',RequestContext(request))
log('MY_EVENT', request.user, t)
在前面的代码中添加这一行后,我得到了一个错误
我有一个错误unexpected indent (tasks.py, line 58)
该错误的原因可能是什么?