Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>There are broadly 3 ways to hold onto this kind of information:</p> <h2>Session (my suggestion for your situation)</h2> <p>Just stuff the data you want into the <code>request.session</code> dictionary; it'll persist per-user, and you can access it easily:</p> <pre><code># view1 request.session['name1'] = male_results request.session['userid1'] = male_pic_userid # view2 (or elsewhere in view1) male_results = request.session.get('name1') male_pic_userid = request.session.get('userid1') </code></pre> <h3>Advantages</h3> <ul> <li>No changes needed to your templates (except removing your now-unnecessary forms).</li> <li>Clean URLs</li> <li>Persists even through closing and re-opening the browser window</li> <li>You don't need to worry about users modifying or even seeing the session data (it's way more secure)</li> </ul> <h3>Disadvantages</h3> <ul> <li>As with <code>POST</code>, page content is dictated by the URL <em>and</em> session data — URLs are no longer unique, and users can't share a particular page that relies on session info</li> </ul> <h2>Query parameters</h2> <p>Something like <code>/match/?name1=foo1&amp;userid1&amp;name2=bar&amp;userid2=2</code>. You can either add these manually (<code>&lt;a href='/match/?name1={{ male_results }}...</code>) or by changing your <code>POST</code> form to <code>GET</code>.</p> <h3>Advantages</h3> <ul> <li>These URLs can be shared and bookmarked; if it's a list with filtering options, this is probably desirable ("Here's the list of cars I like" posted to Facebook, <em>etc.</em>)</li> </ul> <h3>Disadvantages</h3> <ul> <li>As you've already noted, these can be freely modified by the user</li> <li>Adding these to every URL is a massive pain</li> </ul> <h2>POST form (your current approach)</h2> <h3>Advantages</h3> <ul> <li>A little more hidden (nothing user-visible without some kind of browser extension)</li> <li>Slightly harder to manipulate (though don't rely on this security-through-obscurity)</li> <li>Cleaner URLs</li> </ul> <h3>Disdvantages</h3> <ul> <li>Leads to "this page has expired" messages on Internet Explorer if you use your browser's "back" button ...</li> <li>... and "Are you sure you want to re-send this data" messages on most browsers if users try to reload any of your pages</li> <li>All this state information will be lost if a user re-opens the page (pressing "return" in the URL bar, for instance)</li> <li>Users can't share the exact page they're looking at; the content is partly determined by non-user-visible information</li> <li>Adding <code>POST</code> data to every navigation action is a <strong>huge</strong> pain.</li> </ul>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload