These are chat archives for django/django

24th
Feb 2018
Sanjeev Sharma
@thesanjeevsharma
Feb 24 2018 05:42
How get select inputs value in backend? I am getting none.
<form class="col s12" method="get" action="/filterWaste/">
      <div class="row">
        <div class="input-field col s3">
        <select name="name">
          <option value="" disabled selected>Choose customer</option>
          {% for customer in customers %}
            <option value="{{ customer }}">{{ customer }}</option>
          {% endfor %}
        </select>
        <label>Customer</label>
        </div>
        <!--
        <div class="input-field col s3">
          <input type="date" name="date">
        </div>
      -->
        <a href="/filterWaste/" class="btn green accent-4 white-text waves-effect">Filter</a>
      </div>
      </form>

VIEW.PY
def filterWaste(request):
        customer_name = request.GET.get('name')
        print(str(customer_name))
        return render(request, "error.html")
Nnamdi
@nnamdiib
Feb 24 2018 21:34
@thesanjeevsharma The <a> link tag is the cause of your problems, I think.
Sanjeev Sharma
@thesanjeevsharma
Feb 24 2018 21:35
DAMN! It should be a button with type 'submit'.
Nnamdi
@nnamdiib
Feb 24 2018 21:36
@thesanjeevsharma Exactly :)
Sanjeev Sharma
@thesanjeevsharma
Feb 24 2018 21:36
input, actually.
Thank you so much, man! I've been stuck here since 3 days. I'll give it a try.
Nnamdi
@nnamdiib
Feb 24 2018 21:37
Button tag will still work just fine. I did something with Django forms just today, so I'm sure Button works.
@thesanjeevsharma You're welcome!