当前位置: 首页>>代码示例>>Python>>正文


Python Job.name方法代码示例

本文整理汇总了Python中jobs.models.Job.name方法的典型用法代码示例。如果您正苦于以下问题:Python Job.name方法的具体用法?Python Job.name怎么用?Python Job.name使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在jobs.models.Job的用法示例。


在下文中一共展示了Job.name方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_saving_and_retrieving_jobs

# 需要导入模块: from jobs.models import Job [as 别名]
# 或者: from jobs.models.Job import name [as 别名]
    def test_saving_and_retrieving_jobs(self):
        first_job = Job()
        first_job.name = 'first_job_ever'
        first_job.save()

        second_job = Job()
        second_job.name = 'job_number_two'
        second_job.save()

        saved_jobs = Job.objects.all()
        self.assertEqual(saved_jobs.count(), 2)

        first_saved_job = saved_jobs[0]
        second_saved_job = saved_jobs[1]

        self.assertEqual(first_saved_job.name, 'first_job_ever')
        self.assertEqual(second_saved_job.name, 'job_number_two')
开发者ID:trbedwards,项目名称:octodeps,代码行数:19,代码来源:tests.py

示例2: create

# 需要导入模块: from jobs.models import Job [as 别名]
# 或者: from jobs.models.Job import name [as 别名]
def create(request, create_form=CreateJobForm,
           template_name='jobs/create_form.html', success_url=None,
           extra_context=None):
	
	#profile = Profile.objects.get(user_id=request.user.id)
	#if profile and not(profile.if_employer):
	#	return render_to_response('jobs/index.html', {'form': form}, context_instance=RequestContext(request))

	form = create_form()

	if request.method == 'POST':
		form = create_form(request.POST, request.FILES)

		if form.is_valid():
			job = Job()
			job.user = request.user
			job.name = form.cleaned_data['name']
			job.location = form.cleaned_data['location']
			job.intern_project = form.cleaned_data['intern_project']
			job.save()

			# split by new line
			names_values = form.cleaned_data['names_values'].split('\n')
			# go trough all names and values
			for name_value in names_values:
				# skip extra spaces and split by first colon
				result = ' '.join(name_value.split()).split(":", 1)
				# when name and value
				if len(result) == 2:
					parameter = JobParameter()
					parameter.name = result[0].strip()
					parameter.value = result[1].strip()
					parameter.container = job
					parameter.save()

			return redirect('/jobs')
	return render_to_response('jobs/create_form.html', {'form': form}, context_instance=RequestContext(request))
开发者ID:nehulyadav,项目名称:solesite,代码行数:39,代码来源:views.py


注:本文中的jobs.models.Job.name方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。