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 foundI 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.pyI 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 deniedGoogling 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.pyI tried the command again.
$ django-admin.py startproject mysiteAlright, 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.
Comments
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?
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
Thanks, this saved me a ton of time. Worked perfectly.
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
On ubuntu just ommit the .py:
django-admin startproject mysite
and everything works from the start.
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
Thanks for the post. It helped.
If this helps anyone else: my django-admin.py was found at /usr/share/pyshared/django/bin/django-admin.py
python2.7 ubuntu 11.10 (oneiric)