i have a progress with help anyway i am newbie i convert my python script(remember the first script on the first page) to django script on the view
views.py: from django.shortcuts import render_to_response def calc(request): a = [] NList = [] y=0 nums = request.POST['num'] total_inputs = request.POST['total'] for i in range(total_inputs): NList.append(int(num) for num in nums.split(',')) for k in NList: if k is 1: y = 1 elif (k > 1) and (k < 5): y = (k - 1) + 2 a.append(y) return render_to_response('blog/calc.html', { 'a' :a, }) app/urls: urlpatterns = [ url(r'^$',views.calc, name='calc'), ] html form: <form action="" method="POST"> Number of number: <input type="text" name="num" value="Number"> Enter a value: <input type="text" name="total" value="Total value"> <button type="submit" value="Submit"> </form> and i take that error MultiValueDictKeyError at / "'num'" 1. nums = request.POST['num'] Τη Τρίτη, 9 Φεβρουαρίου 2016 - 9:47:30 μ.μ. UTC+2, ο χρήστης Xristos Xristoou έγραψε: > > hello, > > > i create some python mathematical function on python idle, > i want to create website where the user import value numbers on the > function > and take the results from that. > question one,how to connect my mathematical function on the django? > question two,how to connect input and output from the scipts in the > website ? > the second question i ask because input and output from the function is a > dynamic define from the user > > > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/02663377-d462-49eb-900e-a38c954fcee1%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.