title: Dynamically created proxy models do not have listed permissions on admin site
body: <p>Here is my models.py:</p>
  
  <pre><code>class Item(models.Model):
      # ... some irrelevent fields ...
      tags = models.ManyToManyField('Tag')
  
  class Tag(models.Model):
      name = models.CharField(max_lenght=30)
      category_id = models.IntegerField()
  </code></pre>
  
  <p>Tag is actually a general-purpose name. Each item has many different type of tags - currently there are four types: team tags, subject tags, admin tags and special tags. eventually there will probably be a few more.</p>
  
  <p>The idea is, they all have basically the same fields, so instead of having like 4 tables with manytomany relationship, and instead of adding a new column for Item whenever adding a new type, <em>everything</em> is called a 'tag' and it's very easy to add new types without any change to the schema.</p>
  
  <p>Now to handle this in the admin.py I'm using dyamically created proxy models (based on <a href="https://stackoverflow.com/questions/2223375/multiple-modeladmins-views-for-same-model-in-django-admin">this</a>), as such:</p>
  
  <pre><code>def create_modeladmin(modeladmin, model, name = None):
      class  Meta:
          proxy = True
          app_label = model._meta.app_label
  
      attrs = {'__module__': '', 'Meta': Meta}
  
      newmodel = type(name, (model,), attrs)
  
      admin.site.register(newmodel, modeladmin)
      return modeladmin
  
  
  class TagAdmin(models.Model):
      def queryset(self):
          return self.model.objects.filter(category_id = self.cid)
  
  class TeamAdmin(TagAdmin):
      cid = 1
  
  class SubjectAdmin(TagAdmin):
      cid = 2
  # ... and so on ...
  
  create_modeladmin(TeamAdmin, name='Teams', model=Tag)
  create_modeladmin(SubjectAdmin, name='Subject', model=Tag)
  #... and so on ...
  </code></pre>
  
  <p>This works great for me. However, different staff members need different editing permissions - one guy shouldn't access admin tags, while the other should only have access to edit subject-tags and team-tags. But as far as the admin site is concerned - the dynamic models <strong>do not exist in the permission list</strong>, and I can't give anyone permissions regarding them.</p>
  
  <p>i.e. a user given all permissions on the list will still not have access to edit any of the dynamic models, and the only way to let anyone access them at all is to give him a superuser which obviously defies the point</p>
  
  <p>I searched SO and the web and I can't anyone with a similar problem, and the docs don't say anything about this not in the <a href="https://code.djangoproject.com/wiki/DynamicModels" rel="nofollow noreferrer">dynamic models section</a> or the <a href="https://docs.djangoproject.com/en/dev/topics/db/models/#proxy-models" rel="nofollow noreferrer">proxy models section</a>. so I'm guessing this is a different kind of problem. Any help would be greatly appreciated</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>So after some research into it, the answer was simple enough. Since permissions in django are objects that are saved to the database, what I needed to do was simple - add the relevent permissions (and create new ContentType objects as well) to the db, and then I could give people specific pemissions. </p>
  
  <p>However, this raised a new question - is it a good convention to put the function that creates the permissions inside create_modeladmin as a find_or_create sort of function (that basically runs every time) or should it be used as an external script that I should run once every time I add a new dynamic model (sort of like how syncdb does it)?</p>
  
  <p>And is there a way to also create the permissions dynamically (which seems to me like the ideal and most fitting solution)?</p>