Exemple #1
0
def sources_add_submit(request):
	s = Source()
	s.user = request.user
	s.first_name = request.POST['first_name']
	s.last_name = request.POST['last_name']
	s.job_title = request.POST['job_title']
	s.company = request.POST['company']
	s.comments = request.POST['comments']
	s.save()
	return HttpResponseRedirect(reverse('stories.views.sources_index', args=()))
Exemple #2
0
def add_source_api(request):
	sources=json.loads(request.raw_post_data) # the json converter turns it from string to object. 
	a = Source()
	a.user = request.user
	a.first_name = sources["first_name"]
	a.last_name = sources["last_name"]
	a.job_title = sources["job_title"]
	a.company = sources["company"]
	a.comments = sources["comments"]
	a.save()
	result = {}
	result["id"] = a.id
	result["first_name"]=a.first_name	
	result["last_name"]=a.last_name
	return HttpResponse(json.dumps(result,separators=(',',':')))