2

I am of the PHP background and just have started to learn Django and Python (and loving it). I always used to install WAMP server for PHP development.

Now I dont know how do I configure Django to use PostgreSQL i.e how to make both communicate with each other. I have run some 'hello world' scripts with django. Curretly I have installed Python, django and PostgreSQL. here is the version information

  1. Python : 2.7.2 & 3.2 (i have installed both)
  2. Django : 1.3.1
  3. PostgreSQL : 9.1.2
  4. Apache : 2.2 (..this is from WAMP server)
  5. Os : Ms Windows 7 32-bits (x86)

Since django has builtin development server is it at all necessary to have apache installed and use it instead of that one? If we use the built-in server how we are supposed to configure it for PostgreSQL?.

3
  • are you using mod_wsgi on Apache? Commented Feb 20, 2012 at 14:28
  • i dont know this mod_wsgi thing. Apache was installed as a part of WAMP Server which i use for PHP. Commented Feb 20, 2012 at 14:46
  • 1
    For postgresql on Windows, see this answer Commented Feb 20, 2012 at 15:49

3 Answers 3

2

It is not necessary to have apache installed to develop on django. In fact it is often easier to use the development server because it is single threaded, lightweight, and extremely easy to use. python manage.py runserver 0.0.0.0:8080 to run on localhost port 8080, and your code is easily debuggable.

In django you dont configure your server for a database. You configure your project for a database. All database configurations are kept in the settings.py file located in your main project. Page one of the tutorial explains how to set up a database for your django prject. YOu have to specify, database name, host, port, user and password in your settings.py file. https://docs.djangoproject.com/en/dev/intro/tutorial01/#database-setup

I would suggest walking through the django tutorial as it addresses most of the issues in setting up development on a new django project. https://docs.djangoproject.com/en/dev/intro/tutorial01/

Sign up to request clarification or add additional context in comments.

3 Comments

To clarify, though: use the development server for developing. Don't use it for production: for that, you need a proper server (like Apache).
You can use sqlite and not need a database server too.
your answer plus comment by burhan makes it complete for me. All is working fine now.
2

I recently deployed a Django based project and found this tutorial to be very helpful and concise. Django virtualenv Apache2 mod_wsgi

And if you have CentOS, then you can install mod_wsgi as mentioned here: Django Deployment - Setup mod_wsgi on CentOS

Comments

1

Getting Django to run on Apache requires getting Python to interpret that, you can do this with WSGI. follow the tutorial found here:

https://code.djangoproject.com/wiki/django_apache_and_mod_wsgi

there are other methods to deploy this, you can find here:

https://docs.djangoproject.com/en/dev/howto/deployment/

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.