English 中文(简体)
1. 使用以分赠形式标出的员额时的起职错误
原标题:Runtime error while using post methord in forms submision

标题:在Button Click 转口上调Runtime Error(Append Slash)

Description: I m encountering a runtime error when I click the submit button on my form. The error mentions something about appending a slash. I ve tried to understand it, but I m stuck. Can someone please help me figure out what s causing this error and how to resolve it? I m using python with django for my project.

Additional Information:

  • [Provide relevant code snippets if possible]
  • [Any error messages received]

enter image description here

  <form  action="register" method="POST" onsubmit="register">
               {% csrf_token %}
               <h3>my information</h3>
               <h4>Contact us today, and get reply with in 24 hours!</h4>
               <style>
                 fieldset {
                   border: medium none !important;
                   text-emphasis-color:black;
                   margin: 0 0 10px;
                   min-width: 100%;
                   padding: 0;
                   width: 100%;
                   }
               </style>
               <fieldset>
                 <input placeholder="Your name" type="text" tabindex="1" style="background-color:black;"  required autofocus>
               </fieldset><br>
               <fieldset>
                 <input placeholder="Your Email Address" type="email" tabindex="2" style="background-color:black;" required>
               </fieldset><br>
               <fieldset>
                 <input placeholder="Your Phone Number" type="tel" tabindex="3" style="background-color:black;" required>
               </fieldset><br>
               <fieldset>
                 <label for="account">Choose a account:</label>
                   <select name="account" id="name">
                   <option value="netflix">netflix</option>
                   <option value="amazone prime">amazone</option>
                   <option value="disney plus hotstar">hotstar</option>
                   </select>
                   <style>
                   #nname {
                     padding: 5px;
                     color: #f7f7f8;
                     font-size: 12px;
                     background: black;
                     appearance: none;
                 
                 }
               </style>
               </fieldset><br>
               <fieldset>
                 <textarea placeholder="Type your Message Here...." tabindex="5" style="background-color:black;" required></textarea>
               </fieldset><br>
               <fieldset>
                 <button name="submit" type="submit" id="contact-submit" style="background-color:rgb(23, 12, 12);" data-submit="...Sending" value="submit">Submit</button>
               </fieldset><br>
             </form>  

观点。

from django.shortcuts import render,redirect
from django.contrib.auth.models import User
def register(request):
    name=request.POST[ name ]
    email=request.POST[ email ]
    phone_number=request.POST[ phone_number ]
    account=request.POST[ account ]
    message=request.POST[ message ]


    user=User.objects.create_user(name=name)
    print("we wil call back you")
    return redirect( / )

urls。 y

from django.urls import path
from django.views import View

from .import views


urlpatterns = [
        path(  ,views.index,name= index ),
        path( contact/ , views.contact,name= contact ),
        path( ideagained/ ,views.ideagained,name= ideagained ),
        path( idea/ ,views.idea,name= idea ),
        path( ouridea/ ,views.ouridea,name= ouridea ),
        path( aboutpage/ ,views.aboutpage,name= aboutpage ),
        path( register/ ,views.register,name= register )
        
]

问题回答

变化

  <form action="register" method="POST" onsubmit="register">

纽约总部

  <form action="register/" method="POST" onsubmit="register">

这应当做到trick滴。

Otherwise follow the official docs about how 纽约总部 disable append slash





相关问题
How to get two random records with Django

How do I get two distinct random records using Django? I ve seen questions about how to get one but I need to get two random records and they must differ.

Moving (very old) Zope/Plone Site to Django

I am ask to move data from a (now offline) site driven by Plone to a new Django site. These are the version informations I have: Zope Version (unreleased version, python 2.1.3 ) Python Version 2.1....

Can Django models use MySQL functions?

Is there a way to force Django models to pass a field to a MySQL function every time the model data is read or loaded? To clarify what I mean in SQL, I want the Django model to produce something like ...

Flexible pagination in Django

I d like to implement pagination such that I can allow the user to choose the number of records per page such as 10, 25, 50 etc. How should I go about this? Is there an app I can add onto my project ...

is it convenient to urlencode all next parameters? - django

While writing code, it is pretty common to request a page with an appended "next" query string argument. For instance, in the following template code next points back to the page the user is on: &...

Pragmatically adding give-aways/freebies to an online store

Our business currently has an online store and recently we ve been offering free specials to our customers. Right now, we simply display the special and give the buyer a notice stating we will add the ...

热门标签