python-93 Custom Admin Background Management framework component filter, Pop, open usage

Source: Internet
Author: User

Forgotten Knowledge Points:

= Book.object.create (Title=title)

One: Open

Used to implement click to add a book button to pop up a Form Form window page, need to achieve the effect is to click

When the button is submitted, it saves the data to the database, renders the currently submitted book to the specified location, and closes the current window;

<ul>    {% forBookinchBook_list%}        <li>{{Book.title}}</li>    {% ENDFOR%}</ul>"javascript:void (0)"onclick="foo (' Con1 ')"> Click 1</a><p>con1:</p><p id="Con1"></p><a href="javascript:void (0)"onclick="foo (' Con2 ')"> Click 2</a><p>con2:</p><p id="Con2"></p><script>function foo (id) {window.open ("/addbook/?pop_id="+ ID,"","height=400,width=600,top=300,left=300"); } function bar (arg, id) {var ele=document.getElementById (ID); Ele.innerhtml=arg}</script>
View Code
" method="post">    { % csrf_token%}    <p> book name <input type="text" name=" title "></p>    <input type="submit"></form>
View Code
    window.opener.bar ("{{title}}" " {{pop_id}} " );    Window.close ()</script>
View Code
defIndex (Request): Book_list=models. Book.objects.all ()returnRender (Request,'index.html', Locals ())defAddbook (Request):ifRequest.method = ='GET':        returnRender (Request,'addbook.html')    Else: pop_id= Request. Get.get ('pop_id') Title= Request. Post.get ('title') models. Book.objects.create (Title=title)returnRender (Request,'pop.html', locals ())
View Code

Two: POP

Three: Filter

python-93 Custom Admin Background Management framework component filter, Pop, open usage

Related Article

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.