title: When to programmatically create custom Django permissions?
body: <p>The permission/authentication documentation for Django 1.4 provides the following snippet for creating custom permissions programmatically:</p>
  
  <p><strong>Edit:</strong> (I would like to employ this for permissions that are <em>not</em> necessarily linked to a specific model class, but more general permissions that span multiple types.)</p>
  
  <pre><code>from django.contrib.auth.models import Group, Permission
  from django.contrib.contenttypes.models import ContentType
  
  content_type = ContentType.objects.get(app_label='myapp', model='BlogPost')
  permission = Permission.objects.create(codename='can_publish',
                                         name='Can Publish Posts',
                                         content_type=content_type)
  </code></pre>
  
  <p><a href="https://docs.djangoproject.com/en/1.4/topics/auth/#programmatically-creating-permissions" rel="noreferrer">Source</a></p>
  
  <p>My question is <em>where</em> this code should be placed. Obviously these should only be created once, but I don't want to have to do it in the shell. It seems like this should be stored in a file somewhere. (For documentation sake.)</p>