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