Home > Enterprise >  sending data from a "form action" to a views function in django
sending data from a "form action" to a views function in django

Time:12-30

How are you community, I'm a little confused between my newbies and lack of knowledge, I'm working on a small project in Django and I'm also trying to send data from a form action in the html to another view function but I'm not understanding it well How does this work and on top of that I have to send several data not just one and it confuses me even more, I have the following HTML:

{% extends "base.html" %}

{% block content %}

<main >
    <div >
        <div >
            <form action="/interface/" method="POST" >

                <h1>Interface</h1>
                <h4>{{ error }}</h4>
                <select  name="dv">
                    <option selected disabled="True">Select Device</option>
                    {% for device in devicess %}
                        <option>{{ device.id }} - {{ device.name }}</option>
                    {% endfor %}
                </select>
                <br>
                {% csrf_token %}

                <br>
                <button type="submit" >Send</button>
            </form>
                <br>
            {% for interface in interfaces %}       
            <section >
                
                <h2>{{interface.Interface}}</h2>

                {% if interface.Description == "" %} 
                    <p >none description</p>
                {% else %} 
                    <P >{{interface.Description}}</P>                     
                {% endif %}
            
                <form  action= "{% url 'send_description' %}"method="POST">
                    {% csrf_token %}
                    <input type="text" name="command"  placeholder="Change description">
                    <br>
                    <button type="submit" >Send change</button>
                </form>

                <br>

                {% if interface.Status == "up" %} 
                    <p >Interface State:            
  • Related