Hello I'm using django and postgresql. And I'm getting the above error. I have database set up like this:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'django_db',
'USER': 'xxx',
'PASSWORD':'xxxx',
'HOST':'localhost',
'PORT':'5432',
}
}
for problems like this with sqlite, I could've just delete db(mydatabase) but this time I can't see where my db is.
Environment:
Request Method: GET
Request URL: http://127.0.0.1:8000/
Django Version: 1.8.4
Python Version: 2.7.6
Installed Applications:
('django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'main',
'tastypie')
Installed Middleware:
('django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.middleware.security.SecurityMiddleware')
Traceback:
File "/env/local/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
132. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/ebagu/main/views.py" in index
47. post_list = sorted(post_list, key=lambda x: x.get_score(), reverse=True)
File "/env/local/lib/python2.7/site-packages/django/db/models/query.py" in __iter__
162. self._fetch_all()
File "/env/local/lib/python2.7/site-packages/django/db/models/query.py" in _fetch_all
965. self._result_cache = list(self.iterator())
File "/env/local/lib/python2.7/site-packages/django/db/models/query.py" in iterator
238. results = compiler.execute_sql()
File "/env/local/lib/python2.7/site-packages/django/db/models/sql/compiler.py" in execute_sql
840. cursor.execute(sql, params)
File "/env/local/lib/python2.7/site-packages/django/db/backends/utils.py" in execute
79. return super(CursorDebugWrapper, self).execute(sql, params)
File "/env/local/lib/python2.7/site-packages/django/db/backends/utils.py" in execute
64. .cursor.execute(sql, params)
File "/home/younggue/Desktop/ebagu1/env/local/lib/python2.7/site-packages/django/db/utils.py" in __exit__
97. six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/env/local/lib/python2.7/site-packages/django/db/backends/utils.py" in execute
64. return self.cursor.execute(sql, params)
Exception Type: ProgrammingError at /
Exception Value: relation "main_post" does not exist
LINE 1: ...id", "main_post"."views", "main_post"."slug" FROM "main_post...
^
Output from sqlflush
:
BEGIN;
TRUNCATE "django_admin_log", "auth_permission", "auth_group", "auth_group_permissions", "django_session", "auth_user_groups", "auth_user_user_permissions", "main_category", "tastypie_apiaccess", "main_vote", "auth_user", "tastypie_apikey", "django_content_type";
SELECT setval(pg_get_serial_sequence('"django_admin_log"','id'), 1, false);
SELECT setval(pg_get_serial_sequence('"auth_permission"','id'), 1, false);
SELECT setval(pg_get_serial_sequence('"auth_group"','id'), 1, false);
SELECT setval(pg_get_serial_sequence('"auth_user"','id'), 1, false);
SELECT setval(pg_get_serial_sequence('"django_content_type"','id'), 1, false);
SELECT setval(pg_get_serial_sequence('"main_category"','id'), 1, false);
SELECT setval(pg_get_serial_sequence('"main_post"','id'), 1, false);
SELECT setval(pg_get_serial_sequence('"main_vote"','id'), 1, false);
SELECT setval(pg_get_serial_sequence('"tastypie_apiaccess"','id'), 1, false);
SELECT setval(pg_get_serial_sequence('"tastypie_apikey"','id'), 1, false);
COMMIT;
Output from syncdb
/migrate
:
Operations to perform:
Synchronize unmigrated apps: staticfiles, froala_editor, messages, crispy_forms
Apply all migrations: userena, sessions, admin, guardian, tastypie, auth, contenttypes, accounts, main, easy_thumbnails
Synchronizing apps without migrations:
Creating tables...
Running deferred SQL...
Installing custom SQL...
Running migrations:
No migrations to apply.
Uninstalling postgresql with this method: How to thoroughly purge and reinstall postgresql on ubuntu? then reinstalling with help from this youtube video fixed the problem.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With