mardi 12 août 2014

Django 1.6 + postgres 9.3 : je veux la configuration la plus simple possible de la base de données pour le développement sur localhost - Stack Overflow


So I have this in my django settings.py file:


DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'myproj_db',
'USER': 'myproj_user',
'PASSWORD': 'myproj_pw',
'HOST': 'localhost',
'PORT': '5432',
}
}

If I go to my terminal prompt and run psql -d myproj_db -U myproj_user -h localhost -p 5432 I get the following output:


psql (9.3.2)
Type "help" for help.

myproj_db=> \l
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
------------+-------+----------+-------------+-------------+----------------------
jon | jon | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
postgres | jon | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
template0 | jon | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/jon +
| | | | | jon=CTc/jon
template1 | jon | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/jon +
| | | | | jon=CTc/jon
myproj_db | jon | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =Tc/jon +
| | | | | jon=CTc/jon +
| | | | | myproj_user=CTc/jon
(5 rows)

myproj_db->

I then run my usual sequence for rebuilding my django database:


PROMPT> ./manage.py sqlclear data | ./manage.py dbshell
PROMPT> ./manage.py sqlall data | ./manage.py dbshell
PROMPT> ./manage.py flush

and I get the following error:


CommandError: Database myproj_db couldn't be flushed. Possible reasons:
* The database isn't running or isn't configured correctly.
* At least one of the expected database tables doesn't exist.
* The SQL was invalid.
Hint: Look at the output of 'django-admin.py sqlflush'. That's the SQL this command wasn't able to run.
The full error: relation "django_admin_log" does not exist

This is the first I have ever heard of django_admin_log. Have I overlooked something?




I needed to run python manage.py syncdb -- this command built the django_admin_log database table.



So I have this in my django settings.py file:


DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'myproj_db',
'USER': 'myproj_user',
'PASSWORD': 'myproj_pw',
'HOST': 'localhost',
'PORT': '5432',
}
}

If I go to my terminal prompt and run psql -d myproj_db -U myproj_user -h localhost -p 5432 I get the following output:


psql (9.3.2)
Type "help" for help.

myproj_db=> \l
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
------------+-------+----------+-------------+-------------+----------------------
jon | jon | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
postgres | jon | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
template0 | jon | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/jon +
| | | | | jon=CTc/jon
template1 | jon | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/jon +
| | | | | jon=CTc/jon
myproj_db | jon | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =Tc/jon +
| | | | | jon=CTc/jon +
| | | | | myproj_user=CTc/jon
(5 rows)

myproj_db->

I then run my usual sequence for rebuilding my django database:


PROMPT> ./manage.py sqlclear data | ./manage.py dbshell
PROMPT> ./manage.py sqlall data | ./manage.py dbshell
PROMPT> ./manage.py flush

and I get the following error:


CommandError: Database myproj_db couldn't be flushed. Possible reasons:
* The database isn't running or isn't configured correctly.
* At least one of the expected database tables doesn't exist.
* The SQL was invalid.
Hint: Look at the output of 'django-admin.py sqlflush'. That's the SQL this command wasn't able to run.
The full error: relation "django_admin_log" does not exist

This is the first I have ever heard of django_admin_log. Have I overlooked something?



I needed to run python manage.py syncdb -- this command built the django_admin_log database table.


0 commentaires:

Enregistrer un commentaire