Django attracts many non-programmers or programmers that do not have any experience with python. They all run into the same issues while installing and configuring Django. this article is an intent to put an end to all the issues while installing Django. This article is an attempt to put an end to all the issues with installing Django, and is for people running Ubuntu.
Before continuing any further, lets make sure you are running a modern* version of python.
Open a new terminal window and run the following command.
python -c 'import sys; print sys.version[:3]'
This command will output the python version you are running. I recommend using python 2.6 or 2.7. As a side note, Django doesn't work with python 3+. If you are running an older version of python, you will still be able to install Django but part of this tutorial may not apply to your situation.
Make sure you read the articles and follow their instructions before continuing.
Steps to install django on ubuntu.
Congratulations! You now have a running version of django! That wasn't hard at all, now was it?
One of the most debated issues with Django is the difference between an App and a Project. For now it will suffice to know that a project contains multiple apps, and a project more or less equals a website, and an app is just a functionality your website has. Let's go ahead and create our first project!
#make a new directory
mkdir www && cd www
#start a new django project
django-admin.py startproject helloworld
#cd into the newly create project
This will create the following directory structure:
Now use your favorite editor, I recommend using Vim or Gedit, and open the file settings.py. This is what the file should look like:
We need to make some changes to this file to have everything working on our local machine.
I always start my making imports on top of the file and setting my root directory variable.
Then I add myself as one of the admins.
Assuming you have a database name helloworld and are running postgresql as your databse server.
Point your media and static directory to the right paths.
Those two directories(media, static) do not exist yet. You need create them on the same level as your manage.py file. Let's go and create a templates directory that we are going to need next.
mkdir media static templates
Point your templates directory to the right path.
Uncomment the corresponding lines of code to have your INSTALLED_APPS variable look like this.
Your final version of the settings.py file should look something like this: