Django passes parameters via URL (Edit action page)

Source: Internet
Author: User

in the editing section, the idea is to jump to the page in the editor to give him a URL containing a unique ID, and then through the URL of the ID to query the data, the data content displayed on the edit page. 1. Edit button
<button onclick= "window.location= '/edit/{{project.id}}'" ><a href= "/edit/" > Edit </a></ Button>

2.URL configuration, the part enclosed in () is the parameter, if there are multiple parameters, use multiple ()
Urlpatterns = Patterns ("',
......
(' ^edit/(\w+)', Views.edit),
) + static (settings. Static_url, Document_root=settings. Static_root)

the editing method in 3.view.py, the first parameter of each method is the default request, the second argument, the third argument, and so on, can be the parameter obtained from the URL
def edit (Request,param):
Post = project.objects (Id=param) [0]
......
Return Render_to_response ("edit.html", Locals (), Context_instance=requestcontext (Request))

Django passes parameters via URL (Edit action page)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.