title: How to add custom permission to the User model in django?
body: <p>in django by default when syncdb is run with django.contrib.auth installed, it creates default permissions on each model... like foo.can_change , foo.can_delete and foo.can_add. To add custom permissions to models one can add class Meta: under the model and define permissions there, as explained here <a href="https://docs.djangoproject.com/en/4.1/topics/auth/customizing/#custom-permissions" rel="nofollow noreferrer">https://docs.djangoproject.com/en/4.1/topics/auth/customizing/#custom-permissions</a></p>
  <p>My question is that what should I do if I want to add a custom permission to the User model? like foo.can_view. I could do this with the following snippet,</p>
  <pre><code>ct = ContentType.objects.get(app_label='auth', model='user')
  perm = Permission.objects.create(codename='can_view', name='Can View Users', 
                                    content_type=ct)
  perm.save()
  </code></pre>
  <p>But I want something that plays nicely with syncdb, for example the class Meta under my custom models. Should I just have these in class Meta: under UserProfile since that is the way to extend the user model. but is that the RIGHT way to do it? Wouldn't that tie it to UserProfile model?</p>