[Django]-Django only submitting csrf token in forms?

6👍

✅

None of your fields have a name attribute, so the browser sends no data.

You should really be using Django’s forms framework for this, though.

2👍

As mentioned above, you need to specify a “name” attribute in your input fields. You don’t need to use Django forms, but if you are submitting the form normally, any fields you are expecting to be sent need to have a name.

<form action="./validate_code/" method="POST">
    {% if error %}
        <p>Sorry, that wasn't right.</p>
    {% endif %}
    <label for="class_code">Your class code: </label>
    <input type="text" name="class_code" id="class_code">
    <input type="color" name="color">
    {% csrf_token %}
    <button type="submit">Submit</button>
</form>

Leave a comment