Skip to content

Instantly share code, notes, and snippets.

@bsnux
Created January 30, 2013 11:49
Show Gist options
  • Select an option

  • Save bsnux/4672788 to your computer and use it in GitHub Desktop.

Select an option

Save bsnux/4672788 to your computer and use it in GitHub Desktop.

Revisions

  1. Arturo Fernandez created this gist Jan 30, 2013.
    17 changes: 17 additions & 0 deletions gistfile1.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    import pickle

    # Session key
    key = 'my_qs'

    # Pizza => model example
    qs = Pizza.objects.filter(ingredient='tomato')
    # Dumping data
    request.session[key] = pickle.dumps(qs.query)

    # Loading data
    pizzas = Pizza.objects.all()[:1]
    pizzas.query = pickle.loads(request.session[key])

    # Using qs
    for pizza in pizzas:
    print(pizza.ingredient)