这里 Post 表示一篇博客.
related_posts 表示与之相关的其它博客, 目前会返回10篇.
我想把这10篇中的前5篇切片到 x0, 后5篇切片到 x1.
但是给 x1 做完切片后, 发现 x0 也跟着变了, 这是为什么?
>>> from app.models import *
>>> p = Post.objects.get(date_slug='140117-2')
>>> p
<Post: Look in the mirror...redo via 'll'>
>>> x = p.related_posts()
>>> x
[<Post: JJ got a Hart!>, <Post: response to a poem I found >, <Post: RED Hair all the way!>, <Post: Cameron scared of UKIP>, <Post: THE RED HEADED STEPCHILD>, <Post: Are You A Sneaky Person.....????>, <Post: Arisen from the ASH>, <Post: michelle with two 'll' s>, <Post: Webster Rogets, advice on writing >, <Post: Pried then Lied>]
>>> x0 = x[0:5]
>>> x0
[<Post: JJ got a Hart!>, <Post: response to a poem I found >, <Post: RED Hair all the way!>, <Post: Cameron scared of UKIP>, <Post: THE RED HEADED STEPCHILD>]
>>> x1 = x[5:10]
>>> x1
[<Post: Are You A Sneaky Person.....????>, <Post: Arisen from the ASH>, <Post: michelle with two 'll' s>, <Post: Webster Rogets, advice on writing >, <Post: Pried then Lied>]
>>> x0
[<Post: Are You A Sneaky Person.....????>, <Post: Arisen from the ASH>, <Post: michelle with two 'll' s>, <Post: Webster Rogets, advice on writing >, <Post: Pried then Lied>]
>>>
related_posts 表示与之相关的其它博客, 目前会返回10篇.
我想把这10篇中的前5篇切片到 x0, 后5篇切片到 x1.
但是给 x1 做完切片后, 发现 x0 也跟着变了, 这是为什么?
>>> from app.models import *
>>> p = Post.objects.get(date_slug='140117-2')
>>> p
<Post: Look in the mirror...redo via 'll'>
>>> x = p.related_posts()
>>> x
[<Post: JJ got a Hart!>, <Post: response to a poem I found >, <Post: RED Hair all the way!>, <Post: Cameron scared of UKIP>, <Post: THE RED HEADED STEPCHILD>, <Post: Are You A Sneaky Person.....????>, <Post: Arisen from the ASH>, <Post: michelle with two 'll' s>, <Post: Webster Rogets, advice on writing >, <Post: Pried then Lied>]
>>> x0 = x[0:5]
>>> x0
[<Post: JJ got a Hart!>, <Post: response to a poem I found >, <Post: RED Hair all the way!>, <Post: Cameron scared of UKIP>, <Post: THE RED HEADED STEPCHILD>]
>>> x1 = x[5:10]
>>> x1
[<Post: Are You A Sneaky Person.....????>, <Post: Arisen from the ASH>, <Post: michelle with two 'll' s>, <Post: Webster Rogets, advice on writing >, <Post: Pried then Lied>]
>>> x0
[<Post: Are You A Sneaky Person.....????>, <Post: Arisen from the ASH>, <Post: michelle with two 'll' s>, <Post: Webster Rogets, advice on writing >, <Post: Pried then Lied>]
>>>
