ContentType objects only have an indirect relation to models, so you can create
an arbitrary ContentType object in the db and use that for your custom Permission:
url_content_type = ContentType.objects.create(
name='url permission', app_label='crashstats', model='unused')
can_view_url = Permission.objects.create(
name='can view url', content_type=url_content_type,
codename='can_view_url')
user = User.objects.get(username='example_user', is_superuser=False)
user.user_permissions.add(can_view_url)
user = User.objects.get(id=
user.id) # refresh permissions cache
assert user.has_perm('crashstats.can_view_url')
Hope that helps,
Josh
_______________________________________________
dev-webdev mailing list
dev-w...@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-webdev