skip to Main Content

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

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 protected]
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.

2

Answers


  1. You wrote action twice instead of method:

    <form method="POST" action="">
      {% csrf_token %}
      …
    </form>
    Login or Signup to reply.
  2. Your html file should look like this:

    {% extends 'main.html' %}
    
    {% block content %}
    <div>
        <form method="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 %}
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search