title: Archiving Django models
body: <p>I'm creating an online order system for selling items on a regular basis (home delivery of vegetable boxes). I have an 'order' model (simplified) as follows:</p>
  
  <pre><code>class BoxOrder(models.Model):
      customer = models.ForeignKey(Customer)
      frequency = models.IntegerField(choices=((1, "Weekly"), (2, "Fortnightly)))
      item = models.ForeignKey(Item)
      payment_method = models.IntegerField(choices=((1, "Online"), (2, "Free)))
  </code></pre>
  
  <p>Now my 'customer' has the ability to change the frequency of the order, or the 'item' (say 'carrots') being sold or even delete the order all together.</p>
  
  <p>What I'd like to do is create weekly 'backups' of all orders processed that week, so that I can see a historical graph of all the orders ever sold every week. The problem with just archiving the order into another table/database is that if an item (say I no longer sell carrots) is deleted for some reason, then that archived BoxOrder would become invalid because of the <code>ForeignKeys</code></p>
  
  <p>What would be the best solution for creating an archiving system using Django - so that orders for every week in history are viewable in Django admin, and they are 'static' (i.e. independent of whether any other objects are deleted)?
  I've thought about creating a new 'flat' <code>BoxOrderArchive</code> model, then using a cron job to move orders for a given week over, e.g.:</p>
  
  <pre><code>class BoxOrderArchive(models.Model):
      customer_name = models.CharField(max_length=20)
      frequency = models.IntegerField()
      item_name = models.CharField() # refers to BoxOrder.item.name
      item_price = models.DecimalField(max_digits=10, decimal_places=2) # refers to BoxOrder.item.price
      payment_method = models.IntegerField()
  </code></pre>
  
  <p>But I feel like that might be a lot of extra work. Before I go down that route, it would be great to know if anybody has any other solutions?</p>
  
  <p>Thanks</p>