本文整理汇总了Python中tasks.models.Task.import_Tasks方法的典型用法代码示例。如果您正苦于以下问题:Python Task.import_Tasks方法的具体用法?Python Task.import_Tasks怎么用?Python Task.import_Tasks使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tasks.models.Task
的用法示例。
在下文中一共展示了Task.import_Tasks方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: import_tasks
# 需要导入模块: from tasks.models import Task [as 别名]
# 或者: from tasks.models.Task import import_Tasks [as 别名]
def import_tasks(request):
""" View in the admin """
if request.method == 'POST':
form = ImportForm(request.POST, request.FILES)
if form.is_valid():
try:
Task.import_Tasks(form.files['file'], request.user)
messages.success(request, "The import was successfull.")
return HttpResponseRedirect(urlresolvers.reverse('admin:tasks_task_changelist'))
except Exception, e:
from django.forms.utils import ErrorList
msg = "An Error occured. The import file was propably malformed.: %s" % str(e)
form._errors["file"] = ErrorList([msg])
示例2: import_tasks
# 需要导入模块: from tasks.models import Task [as 别名]
# 或者: from tasks.models.Task import import_Tasks [as 别名]
def import_tasks(request):
""" View in the admin """
if request.method == 'POST':
form = ImportForm(request.POST, request.FILES)
if form.is_valid():
try:
Task.import_Tasks(form.files['file'], request.user)
request.user.message_set.create(message="The import was successfull.")
return HttpResponseRedirect(urlresolvers.reverse('admin:tasks_task_changelist'))
except:
from django.forms.util import ErrorList
msg = "An Error occured. The import file was propably malformed."
form._errors["file"] = ErrorList([msg])
else:
form = ImportForm()
return render_to_response('admin/tasks/task/import.html', {'form': form, 'title':"Import Task" }, RequestContext(request))