Hi Guys, I came here for a question.

Few days ago, I made some app(i.e. proxy_polls) and happened to put proxy 
models(i.e. ProxyQuestion, ProxyChoice) into *admin.py* (which is not 
adequate place), and I didn't make *models.py*.

After running 'makemigrations' and 'migrate' commands, I realized there is 
no permissions with proxy models. With admin user, I can use proxy models 
on admin page, but staff users can't access to proxy models because I can't 
set permissions.

I know this ticket <https://code.djangoproject.com/ticket/11154> fixed 
issue about proxy model's permission, but similar issue has happened.

After some attempts, I was able to find a solution. Just make empty 
'models.py' on proxy app and run 'migrate'. Django prints out "No 
migrations to apply." but after that, permission has been created.

If there are some messages like "You don't have models.py!" or "No 
migrations to apply, but made some missed permissions.", I think It is 
helpful.


For those who are curious about how to reproduce,

   1. django-admin startproject mysite
   2. cd mysite
   3. startapp polls
   4. (Make Question, Choice models on polls/models.py, set INSTALLED_APPS, 
   register models on admin site)
   5. makemigrations
   6. startapp proxy_polls
   7. (Make ProxyQuestion, ProxyChoice models on proxy_polls/admin.py, 
   remove proxy_polls/models.py, set INSTALLED_APPS, register proxy models on 
   admin site)
   8. makemigrations -> For now, there are no permissions about 
   'ProxyQuestion' and 'ProxyChoice'
   9. (Create empty models.py)
   10. migrate (No migrations to apply) -> now, there are permissions.

I've done this on Django 4.0-dev with python 3.10

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/d5ab7a52-7f38-440b-a0fd-b56300db4d1en%40googlegroups.com.

Reply via email to