Saltycrane logo

SaltyCrane Blog

Notes on Python, Django, and web development on Ubuntu Linux

    

Django project #1: Install

I plan to do a side project in Django just to get some web programming experience. I'm not sure exactly what the site will be yet. Maybe my very own blog software with extensive tagging capabilities and maybe revision control. I also have an idea for a site to specialize in comparison searching. E.g. "python vs. ruby", "mac vs. linux", "kde vs. gnome", etc. Or, if I find someone who needs a website, I might work someone else's project. As long as I get to choose the technology. Anyways, I plan to document my steps here. I've already installed Ubuntu. Here are my steps in creating my Django website.

Install django

$ sudo apt-get install python-django

Test install

To test the install, I typed import django in the python interpreter.

$ python
Python 2.5.1 (r251:54863, Oct  5 2007, 13:36:32) 
[GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import django
>>> 
Alright, It worked.



Create a project

I tried to follow the Django tutorial and ran the django-admin.py command. However, I got the command not found error message.

$ django-admin.py startproject mysite
bash: django-admin.py: command not found
I googled for the error message and found this link which said to link the django-admin.py file to a location in your path.
$ sudo ln -s /usr/lib/python-django/bin/django-admin.py /usr/local/bin/django-admin.py
I tried the django-admin.py command again, and now got a Permission denied error.
$ django-admin.py startproject mysite
bash: /usr/local/bin/django-admin.py: Permission denied
Googling again, I found the SVN release version of the tutorial which gave instructions about the Permission denied error. (I was using the 0.96 version of the tutorial). So I changed the permissions of the django-admin.py file to be executable.
$ sudo chmod +x /usr/lib/python-django/bin/django-admin.py
I tried the command again.
$ django-admin.py startproject mysite
Alright, success! I got no errors.



Start the development web server

$ cd mysite
$ python manage.py runserver
Validating models...
0 errors found.

Django version 0.96, using settings 'mysite.settings'
Development server is running at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
Alright, it worked! I know you are excited. I visited http://127.0.0.1:8000/ in my browser and got a nice page affirming me of my success.

It worked!
Congratulations on your first Django-powered page.

This seems like a good stopping point. The next step is setting up the database.

6 Comments — feed icon Comments feed for this post


#1 Lopsta Ecommerce commented on 2008-11-24:

i'm at the same point, but i don't know where to link the admin file to. i'm on a mac. do i have to link to the folder that i'm using django-admin.py from?


#2 mc commented on 2008-11-26:

Lopsta

Here is my path on mac os x 10.5.5

sudo ln -s /opt/local/Library/Frameworks/Python.framework/Versions/2.5/bin/django-admin.py /usr/local/bin/django-admin.py

but just do a search for django-admin.py and note the path. go from wherever it really is to /usr/local/bin/django-admin.py

I have a different problem, when I attempt to start the webserver I get

Unhandled exception in thread started by -function inner_run at 0x65bdb0-

lots of file validation errors (well, 4) then

ImportError: No module named dummy.base


#3 Ben commented on 2009-03-01:

Thanks, this saved me a ton of time. Worked perfectly.


#4 Darcy commented on 2009-03-04:

To mc,

Hi,

I met the same problem of ImportError: No module named dummy.base Could you please tell me how you solved it?

Thank you. Darcy


#5 jmfrank63 commented on 2009-08-17:

On ubuntu just ommit the .py:

django-admin startproject mysite

and everything works from the start.


#6 Cody commented on 2010-02-12:

Thanks for the help! My running shoe review site will soon be totally django powered after I get through the django book.

After looking over the django framework, and at the source code, what they've done abstracting everything to this level is amazing.

Again, thanks for the blog post.

  • Cody

Post a comment

Required
Required, but not displayed
Optional

Format using Markdown. (No HTML.)
  • Code blocks: prefix each line by at least 4 spaces or 1 tab (and a blank line before and after)
  • Code span: surround with backticks
  • Blockquotes: prefix lines to be quoted with >
  • Links: <URL>
  • Links w/ description: [description](URL)
Created with Django | Hosted by Slicehost