Django: I get [the relation "auth_group" does not exist] error after syncdb

I started a new Django 1.8 project and realized that I was missing something (I did the initial migrations). I deleted the database (postgreSQL) and deleted the migration folders from all my applications to start from scratch.

Now that I am 'syncdb', I get this error:

django.db.utils.ProgrammingError: relation "auth_group" does not exist

and when I makemigrations , I get the following:

No changes detected

What am I doing wrong?

+7
source share
7 answers

Perhaps you should try to create migrations modules (folders named migrations with an empty file named __init__.py inside each directory) for your applications. Then run manage.py makemigrations .

+19
source

The problem is no changes detected . Run these commands with your application name. I think you did not add it (just like I made a mistake):

  • python manage.py makemigrations myappname
  • python manage.py migrate myappname
+5
source

Running ./manage.py migrate auth did not work for me at first, and every ./manage.py command ./manage.py this error. My problem was that I was doing things with the Group manager in the module area.

If you have code like this in the scope of a module:

 customers_group = Group.objects.get(name='customers') 

Move it inside the function that is called at runtime.

 def xyz(): ... customers_group = Group.objects.get(name='customers') 
+2
source

The above error occurs when installed django.contrib.admin . Run these commands in the appropriate order.

 ** ./manage.py makemigrations ./manage.py migrate auth ./manage.py migrate** 

It worked fine for me.

0
source

It could be:

  • one of pip dependencies on requirements. txt used south

    had this error when running tests that migrate to Django 1.8. Found lib with problem by running tests in verbose mode. Consider upgrading the library to a newer version.

manage.py test -v 3

  • There may still be old south migration files in one of the / migrations folder. This may be due to other users continuing to add migrations when you try to upgrade Django. Use the following to verify that the expected migration files are present in each application.

manage.py management impressions

0
source

I had a similar issue with Django2.2 migrations. I will post what helped if someone wants to fix it.

I commented out all the application urls (e.g. my_app.urls, your_app.urls) in the main urls.py project, and then ran makemigrations and it worked. I think this error is due to some forms / views referring to the model / fields that have not yet been created. Django seems to cross urls.py before migration

0
source

: django.contrib.auth in INSTALLED_APPS?

-1
source

Source: https://habr.com/ru/post/987860/


All Articles