Not sure if this is bug or not

16 views
Skip to first unread message

vincent

unread,
Mar 7, 2021, 11:38:12 AM3/7/21
to Django users
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 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
Reply all
Reply to author
Forward
0 new messages