Beispiel #1
0
def Contact_upload(request):
	template = "Contact_upload.html"

	prompt = {
		'order': 'Order of the CSV should be first_name, last_name, email, message',
			}
			  
	if request.method =="GET":
		return render(request, template, prompt)
	    
	csv_file = request.FILES['file']

	if request.method=='POST':			
		data_set = pd.read_csv(csv_file,encoding='utf8')
		
		conts=models.Contacts(data_set)
		conts.save()
		prompt["file_upload"]="the file is uploaded successfully."
		return render(request, template, prompt)

		=====================================================================================
Beispiel #2
0
def Contact_upload(request):
	template = "Contact_upload.html"

	prompt = {
		'order': 'Order of the CSV should be first_name, last_name, email, message',
			}
			  
	if request.method =="GET":
		return render(request, template, prompt)
		csv_file = request.FILES['file']
	# data_set = csv_file.read().decode('UTF-8')
	#conn = psycopg2.connect("host=localhost dbname=second user=postgres password=killer999")
	#cur = conn.cursor()
	elif request.method=='POST':
		conts=models.Contacts(
    		first_name = "Josh",
    		last_name = "Man",
    		email = "*****@*****.**",
    		message = "hello data"
    		)
		conts.save()
		prompt["file_upload"]="the file is uploaded successfully."
		return render(request, template, prompt)
Beispiel #3
0
def Contact_upload(request):
	template = "Contact_upload.html"

	prompt = {
		'order': 'Order of the CSV should be first_name, last_name, email, message',
			}
			  
	if request.method =="GET":
		return render(request, template, prompt)
	    
	csv_file = request.FILES['file']

	if request.method=='POST':			
		data_set = pd.read_csv(csv_file).encoding='utf8'
		io_string = io.StringIO(data_set)
		next(io_string) # Skip the header row.
		for column in csv.reader(io_string, delimiter=',', quotechar="│"):
			conts=models.Contacts(data_set)
			conts.save()
		prompt["file_upload"]="the file is uploaded successfully."
		return render(request, template, prompt)

		========================================================================================
Beispiel #4
0
		form =ContactForm()

	context = {
	     'form':form,
	}
	return render(request,template,context)


@permission_required('admin.can_add_log_entry')

def Contact_upload(request):
	template = "Contact_upload.html"

	prompt = {
		'order': 'Order of the CSV should be first_name, last_name, email, message',
			}
			  
	if request.method =="GET":
		return render(request, template, prompt)
	    
	csv_file = request.FILES['file']

	if request.method=='POST':			
		data_set = pd.read_csv(csv_file,encoding='utf8')
		first_name= (data_set['first_name']),
		last_name = (data_set['last_name']),
		email = (data_set['email']),
		message = (data_set['message'])
conts=models.Contacts('id','first_name' ,'last_name' ,'email','message')
conts.save()