Thursday, October 31, 2013

Re: 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)

On Wednesday, 30 October 2013 20:17:17 UTC, pete wrote:
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 %}


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.

--
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/8e41088b-cd19-468f-8c73-0a67e4d847b4%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment