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.


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

        miFormulario = ferrocarrilFormulario(request.POST)


        if miFormulario.is_valid:

            informacion = miFormulario.cleaned_data

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

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


from django import forms

class ferrocarrilFormulario(forms.Form):

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

Form HTML:

<!DOCTYPE html>
<html lang="en">
    <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>

    {% if.miFormulario.errors %}

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

    {% endif %}

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


            {{ miFormulario.as_tabble }}


        <input type="submit" value="Enviar">


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