Fixing – Django admin permissions not getting updated after adding model proxy

Django problem:

I added a new model proxy to my models.py and then registered it on admin.py but the permissions for the new model were not showing up in the add user permissions section of the admin page even after doing a syncdb.

To fix I manually added it to the tables using the SQL below:

INSERT INTO django_content_type (name,app_label,model)
VALUES ('User Activity','VisitorLog','logentryforvisitorlogonlyproxy');
-- Use ID from insert above to fill in below
INSERT INTO auth_permission (name,content_type_id,codename)
VALUES ('Can add User Activity',12,'add_permission');
INSERT INTO auth_permission (name,content_type_id,codename)
VALUES ('Can change User Activity',12,'change_permission');
INSERT INTO auth_permission (name,content_type_id,codename)
VALUES ('Can delete User Activity',12,'delete_permission');

One Response to “Fixing – Django admin permissions not getting updated after adding model proxy”

  1. JoeZ99 says:

    Hi there! I faced the exact same issue than you. Surprisingly there is no other guy over there that has gone through this (apparently).

    Anyway, I neeed it to be compatible with a migration process, so I dig a little more and came out with this:
    http://dev.markhaus.com/blog/2011/04/django-admin-permissions-and-contenttype-table-doesnt-update-when-adding-proxy-models/

    I hope you find it usefull