update my code khow i feel so close but not work again hahaha to many problems
Τη Τρίτη, 9 Φεβρουαρίου 2016 - 9:47:30 μ.μ. UTC+2, ο χρήστης Xristos Xristoou έγραψε:
-- . I want to write a django code which takes a number and a list of numbers from the website as user input and and then export a list with results. but if i run my app don't show me results from the progress in html template, i can only input details if i push second button just reload the page and not show me results.
I have written following code but it doesn't show me the results:
views.py
def calc(request): NList=[] num=0 a=[] y=0 c=0 total=0 num = request.POST.get ('num', False) if request.method=='POST' and 'btnform1' in request.POST: b='1'.zfill(int(num)) e=b[::-1] c=int(e) #num=int(num) if request.method=='POST' and 'btnform2' in request.POST: for i in range(int(num)): total = request.POST.get ('total', False) NList.append(int(total)) for k in NList: if k == 1: y=1 elif (k > 1) and (k < 5): y = k+1000 a.append(y) return render_to_response ('blog/calc.html', {'a' :a,'num':num,'c':c,'y':y,'total':total,'NList':NList},context_instance=RequestContext(request))
html form
form id="form1" action="" method="POST">{% csrf_token %} <div> Number of number: <input type="text" name="num" value="Number"/> <div> <button type="submit" name="btnform1">count</button> </div> </div> <p> {{num}} </p> </form> <form id="form1" action="" method="POST">{% csrf_token %} <div> {% for i in c|make_list %} Enter a value: <input type="text" name="total" value="Total value"> {% endfor %} <div> <button type="submit" name="btnform2">final</button> </div> </div> </form> <p> {{ a}} or full info {% for sm in a %} {{ sm }} {% endfor %} </p>
urls.py
url(r'^$',views.calc, name='calc'),
this is a example if if the first input is num=4 then the script create 4 html inputs field(to user input second number list total) but if i click final button dont show me resust(a=output).
Τη Τρίτη, 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 functionand 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+unsubscribe@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/d64a4f0a-6c20-48c8-ab4e-930fcb3c0d08%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment