title: INSERT or UPDATE on PostgreSQL views
body: <p>I'm starting with PostgreSQL views, since they are useful for my use case and will provide better performance than functions.</p>
  
  <p>(This isn't relevant, but I'm using Django 1.7 on Heroku Postgres&mdash;just in case).</p>
  
  <p>I have already created a view and can query it fine. I'd like to write a Django wrapper around the view so I can treat it like a table, and query and write to it accordingly.  I've been reviewing the 
  <a href="http://www.postgresql.org/docs/9.4/static/rules-update.html" rel="noreferrer">Postgres docs on <code>INSERT</code> and <code>UPDATE</code> for views</a> but to be honest I find their docs so hard to read I can barely parse through what they're saying.</p>
  
  <p>Let's say I have the following view:</p>
  
  <pre><code>CREATE OR REPLACE VIEW links AS
    SELECT
      listing.id                                                     AS listing_id,
      CONCAT('/i-', industry.slug, '-j-', listing.slug, '/') AS link,
      'https://www.example.com' || CONCAT(industry.slug, '-SEP-', listing.slug, '/') AS full_link,
      listing.slug AS listing_slug,
      industry.slug AS industry_slug
    FROM listing
      INNER JOIN company ON company.id = listing.company_id
      INNER JOIN industry ON industry.id = company.industry_id
  </code></pre>
  
  <p>Here, I'm using <code>industry.slug</code> and <code>listing.slug</code> to build links. I'd like to be able to update those two fields from this view, as such:</p>
  
  <pre><code>UPDATE links
  SET listing_slug = 'my-new-slug'
  WHERE listing_id = 5;
  </code></pre>
  
  <p>How do I create the rules to do this properly?</p>