2

Hi i am very green at django and just learnt python. I'm struggling to set it all up right. So apologies now!

I have django and python installed (windows 7). Everything in tutorial has worked (sort of) up to now. Now trying to syncdb my first db as in tutorial posts. I've created one in myadmin III called posts and my setting.py file looks like..

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'NAME': os.path.join(BASE_DIR, 'C:/Program Files/PostgreSQL/9.3/data/base/polls.db'),
        'PASSWORD': '',

However i get this error (amongst others)

conn = _connect(dsn, connection_factory=connection_factory, async=async)
django.db.utils.OperationalError: fe_sendauth: no password supplied

The dbase does not seem to have a password set nor the server connection in postgresql. So don't know what i need to do?

What password should i use?

Many thanks!

SandBlack
  • 71
  • 1
  • 5

2 Answers2

3

I'm assuming that going through the tutorial, you're working on your local machine with the development server (manage.py runserver). In this case, I'd recommend just to use sql lite as it seems you are trying to do in your settings.

The following should work fine for you to get syncdb to work.

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3', 
        'NAME': os.path.join(BASE_DIR, 'polls.db'), #name field represents filepath for sqlite
    }
}

If you want to be using a local instance of postgres though, you'll want to specify the database name in the name parameter. It'll look more like

DATABASES = {
  'default': {
    'ENGINE': 'django.db.backends.postgresql_psycopg2',
    'NAME': 'polls', # name of psql db on your running database server
    'HOST': 'localhost', #assuming psql is running locally
    'PORT': 5432,
    'USER': 'username', #admin username that you set up with no password
    'PASSWORD': '', 
  }
}
Tim Edgar
  • 2,143
  • 14
  • 11
  • With django you can use multiple database backends sqlite is one of the easiest to setup and maintain as it requires no additional programs to run. See https://docs.djangoproject.com/en/1.5/ref/databases/ for more information. – gnur Oct 18 '13 at 08:17
0

You should create a user in postgres and use this account's settings (user and pass).

OBu
  • 4,977
  • 3
  • 29
  • 45