New to django,need help! just trying to retrieve values from a template to a view.py (ie user may input text, make choice selection, select a radio button value)

381 views
Skip to first unread message

pete

unread,
Oct 30, 2013, 4:17:17 PM10/30/13
to django...@googlegroups.com
Hi
New to django,need help!  just trying to retrieve values from a template to a view.py (ie user may  input text, make choice selection, select a radio button value)
like to know the poll list section, market selection, coupon code, and discount text, and poll choice selection from radio button
 
view
def current_datetime(request):
 
 current_date = datetime.datetime.now()
 latest_poll_list = Poll.objects.filter( pub_date__lte=timezone.now()).order_by('-pub_date')[:5]
 all_entries = FStatistics.objects.all()
 return render_to_response('polls/current_datetime.html', locals())
 
=====================================================
 
current_datetime.html' Template  like
 
{% load staticfiles %}
<link rel="stylesheet" type="text/css" href="{% static 'polls/style.css' %}" />
 
{% if latest_poll_list %}
    <ul>
    {% for poll in latest_poll_list %}
        <li><a href="{% url 'polls:detail' poll.id %}">{{ poll.question }}</a></li>
    {% endfor %}
    </ul>
{% else %}
    <p>No polls are available.</p>
{% endif %}
<br>

<html><body>Markets</body></html><br>
<select name="market" id="marketid" size="2" multiple="multiple">
    <option value="0">All</option>
   {% for stat in all_entries %}
     <option value="{{ stat.id }}">{{ stat.market }}</option>
    {% endfor %}
   
</select>
 
 <label for="user">Coupon code :</label>
        <input type="text" id="coupon_Code" maxlength="100"  />
        <br>
        <label for="user">Discount :</label>
        <textarea rows="2" cols="19" minlength="15" id="coupon_Discount"></textarea>
        <br>

{% for choice in poll.choice_set.all %}
    <input type="radio" name="choice" id="choice{{ forloop.counter }}" value="{{ choice.id }}" />
    <label for="choice{{ forloop.counter }}">{{choice.id }} - {{ choice.choice }}</label><br />
{% endfor %}

Daniel Roseman

unread,
Oct 31, 2013, 6:34:35 AM10/31/13
to django...@googlegroups.com
You don't say exactly what your question is, but seems like you need to do an HTML tutorial. There's plenty about this template that makes no sense - particularly the random <html> tag in the middle (that should go around the whole content, not just the <h1>), but in particular you seem to have missed off a <form> tag and a submit button that would allow you to submit the form.
--
DR.

mmrs151

unread,
Oct 31, 2013, 11:45:53 AM10/31/13
to django...@googlegroups.com
So what is the problem, really?


On Wednesday, 30 October 2013 20:17:17 UTC, pete wrote:

Jimmy Pants

unread,
Nov 1, 2013, 3:52:49 AM11/1/13
to django...@googlegroups.com
Expanding on Daniel Roseman's suggestion, I recommend the Web Fundamentals course at www.codecademy.com - totally free, and pretty good, covers CSS stylesheets as well.
Reply all
Reply to author
Forward
0 new messages