liaison nouveau User dans le setting.py ne fonctionne pas
Bonjour,
Je suis sur windows. J'utilise le Shell pour créé un nouvel utilisateur et les rôles qui lui sont associés sans souci.
Avec la commande `\du` l'utilisateur apparait correctement. Je vérifie ensuite la liste des bases de données avec `\l` dans la colonne des droit d'accés en ligne de mon nouveau User il y a ce message :
```
=Tc/postgres
postgres=CTc/postgres
blogadmin=CTc/postgres
```
Donc si je ne me trompe pas la fonction GRANT à bien fonctionné. Dans setting.py je rentre les informations suivante (celle que j'ai rentré dans le shell) :
```
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'blog',
'USER': 'blogadmin',
'PASSWORD': '123456',
'HOST': 'localhost',
'PORT': '5432',
}
}
```
Quand je fait un `python manage.py migrate` il y a un message d'error.
```
(venv) PS C:\Users\yann\Desktop\Developpeur\Python\Exercice Django\django_blog\src> python manage.py migrate
Operations to perform:
Apply all migrations: admin, auth, contenttypes, sessions
Running migrations:
Traceback (most recent call last):
File "C:\Users\yann\Desktop\Developpeur\Python\Exercice Django\django_blog\venv\lib\site-packages\django\db\backends\utils.py", line 82, in _execute
return self.cursor.execute(sql)
psycopg2.errors.InsufficientPrivilege: ERREUR: droit refusé pour le schéma public
LINE 1: CREATE TABLE "django_migrations" ("id" serial NOT NULL PRIMA...
^
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\yann\Desktop\Developpeur\Python\Exercice Django\django_blog\venv\lib\site-packages\django\db\migrations\recorder.py", line 68, in ensure_schema
editor.create_model(self.Migration)
File "C:\Users\yann\Desktop\Developpeur\Python\Exercice Django\django_blog\venv\lib\site-packages\django\db\backends\base\schema.py", line 324, in create_model
self.execute(sql, params or None)
File "C:\Users\yann\Desktop\Developpeur\Python\Exercice Django\django_blog\venv\lib\site-packages\django\db\backends\base\schema.py", line 142, in execute
cursor.execute(sql, params)
django.db.utils.ProgrammingError: ERREUR: droit refusé pour le schéma public
LINE 1: CREATE TABLE "django_migrations" ("id" serial NOT NULL PRIMA...
^
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\yann\Desktop\Developpeur\Python\Exercice Django\django_blog\src\manage.py", line 22, in <module>
main()
File "C:\Users\yann\Desktop\Developpeur\Python\Exercice Django\django_blog\src\manage.py", line 18, in main
execute_from_command_line(sys.argv)
File "C:\Users\yann\Desktop\Developpeur\Python\Exercice Django\django_blog\venv\lib\site-packages\django\core\management\__init__.py", line 401, in execute_from_command_line
utility.execute()
File "C:\Users\yann\Desktop\Developpeur\Python\Exercice Django\django_blog\venv\lib\site-packages\django\core\management\__init__.py", line 395, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Users\yann\Desktop\Developpeur\Python\Exercice Django\django_blog\venv\lib\site-packages\django\core\management\base.py", line 330, in run_from_argv
self.execute(*args, **cmd_options)
File "C:\Users\yann\Desktop\Developpeur\Python\Exercice Django\django_blog\venv\lib\site-packages\django\core\management\base.py", line 371, in execute
output = self.handle(*args, **options)
File "C:\Users\yann\Desktop\Developpeur\Python\Exercice Django\django_blog\venv\lib\site-packages\django\core\management\base.py", line 85, in wrapped
res = handle_func(*args, **kwargs)
File "C:\Users\yann\Desktop\Developpeur\Python\Exercice Django\django_blog\venv\lib\site-packages\django\core\management\commands\migrate.py", line 243, in handle
post_migrate_state = executor.migrate(
File "C:\Users\yann\Desktop\Developpeur\Python\Exercice Django\django_blog\venv\lib\site-packages\django\db\migrations\executor.py", line 91, in migrate
self.recorder.ensure_schema()
File "C:\Users\yann\Desktop\Developpeur\Python\Exercice Django\django_blog\venv\lib\site-packages\django\db\migrations\recorder.py", line 70, in ensure_schema
raise MigrationSchemaMissing("Unable to create the django_migrations table (%s)" % exc)
django.db.migrations.exceptions.MigrationSchemaMissing: Unable to create the django_migrations table (ERREUR: droit refusé pour le schéma public
LINE 1: CREATE TABLE "django_migrations" ("id" serial NOT NULL PRIMA...
```
Je m'excuse pour le grand message d'erreur, j'ai lu et essayé d'interprété mais je n'ai pas encore les connaissances. Il est histoire de droit mais je ne sais pas ou cherché si j'ai bien utilisé la commande GRANT.
Mais quand je remplace l'USER par le super utilisateur créé à l'installation de POSTGRESQL, c'est à dire `postgres` dans le USER et le mot de passe de l'installation la migration fonction très bien et en utilisant `\dt ` j'ai bien les informations qui son remonté sur ma base de données.
Merci d'avance, bonne journée.
Yann</module>