Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

The current path, **/POST, didn’t match any of these

I have a login page that has an auth form, 2 values, after validation, redirect it with these 2 parameters, but i get an error, what did i miss?

The Views

def LoginPage(request):
    if request.method == "POST":
        ordernr = request.POST.get('bestellnummer')
        email = request.POST.get('email')
        try:
            ...."validation shopify api"
        else:
            return redirect(f'login/{ordernr}/{email}/')

the urls app

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

urlpatterns = [
    path('login/', views.LoginPage, name="login"),
    path('login/<str:pk>/<str:dk>/', views.OrderPage, name="order"),
]

the from

{% extends 'main.html' %}

{% block content %}
    <div>
        <form action="POST" action="">{% csrf_token %}
            <div>
                <label for="bestellnummer">Ihre Bestellnummer</label>
                <input type="text" name="bestellnummer" id="bestellnummer" placeholder="Ihre Bestellnummer...">
            </div>
            <div>
                <label for="email">Ihre Bestell E-Mail</label>
                <input type="email" name="email" id="email" placeholder="Ihre E-Mail...">
            </div>
            <input type="submit" value="Login">
        </form>

    </div>
{% endblock content %}

Page not found (404) your text
Request Method: GET
Request URL: http://127.0.0.1:8000/login/POST?csrfmiddlewaretoken=token123&bestellnummer=1337&email=somefiller@mail.com
Using the URLconf defined in retourenportal.urls, Django tried these URL patterns, in this order:

admin/
login/ [name=’login’]
login/str:pk/str:email/ [name=’order’]
The current path, login/POST, didn’t match any of these.

>Solution :

You wrote action twice instead of method:

<form method="POST" action="">
  {% csrf_token %}
  …
</form>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading