title: Standard way to load initial (and ongoing) data into Django
body: <p>Suppose I have a model with a field that restricts another model.  For example, a <code>Thing</code> whose <code>name</code> has to be in the current set of <code>AllowedThingNames</code>.  The set of allowed_thing_names changes (infrequently) by an external source.  I have code to get that external source and create <code>AllowedThingNames</code> as needed.  </p>
  
  <p>Here is some code:</p>
  
  <p><strong>models.py:</strong></p>
  
  <pre><code>class AllowedThingName(models.Model):
    name = models.CharField(max_length=100, unique=True)
  
  class Thing(models.Model):
    name = models.CharField(max_length=100)
  
    def __save__(self, *args, **kwargs):
      if AllowedThingName.objects.filter(name=self.name).exists():
        return super().save(*args, **kwargs)
      return None
  </code></pre>
  
  <p><strong>tasks.py:</strong></p>
  
  <pre><code>@shared_task
  def import_new_names():
    response = request.get("some/external/url/where/allowed/names/are/listed")
    new_names = clever_way_of_parsing_response(response.content)
    for new_name in new_names:
      AllowedThingName.objects.get_or_create(name=new_name)
  </code></pre>
  
  <p>I have created a fixture of <code>AllowedThingNames</code> and I run the <code>loaddata</code> command at startup.  </p>
  
  <p>I'm not sure what the best way is to keep the set of <code>AllowedThingNames</code> up-to-date, though.</p>
  
  <p>One solution is to periodically (via a task, or a cronjob, or whatever) call the <code>import_new_names</code> function above and then call <code>dumpdata</code> to overwrite the fixture.  This will save it in the db and make sure that it gets re-loaded the next time the project restarts.</p>
  
  <p>Does anybody in StackOverflow-Land have any better ideas?</p>