FerrocarrilFormulario() missing 1 required positional argument: 'request'

I need help with my code, I'm making a form in django and I can't solve this error.

views.py:

def ferrocarrilFormulario(request):
    
    if request.method =="POST":

        miFormulario = ferrocarrilFormulario(request.POST)

        print(miFormulario)

        if miFormulario.is_valid:

            informacion = miFormulario.cleaned_data

            ferrocarril = ferrocarril(request.POST["tipo"], request.POST["precio"])
    
            ferrocarril.save()

            return render (request, "AppCoder/inicio.html")

Forms.py:

from django import forms

class ferrocarrilFormulario(forms.Form):

    tipo= forms.CharField()
    precio = forms.IntegerField()

Form HTML:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Agrega un ferrocarril</title>
</head>
<body>

    {% if.miFormulario.errors %}

    <p style="color: red;"> Datos mal ingresados</p>

    {% endif %}


    <form action="" method="POST"{% csrf_token %}

        <table>

            {{ miFormulario.as_tabble }}

        </table>
    


        <input type="submit" value="Enviar">
    
    ></form>
</body>
</html>

urls.py:

from django.urls import path
from AppCoder import views

urlpatterns = [
    path('',views.inicio, name="Inicio"),
    path("ferrocarril/", views.ferrocarril, name="ferrocarril"),
    path("vias/", views.vias, name="vias"),
    path("manodeobra/", views.manodeobra, name="manodeobra"),
    path("tables.html/", views.tables, name="tables"),
    path("ferrocarrilFormulario/", views.ferrocarrilFormulario, name="ferrocarrilFormulario")

thank you <3

I wanted the form to work after that, but that is not the case.

PS: if I put the request, it generates another error, and in the tutorial it appears without the request.

Thanks again.

Back to Top