Difference between revisions of "Django"

From ArchWiki
Jump to: navigation, search
m
(since python package renamed python2 and python3 renamed python, django doesn't support python3 yet.)
Line 23: Line 23:
 
This will create the directory ''myproject'' under the current directory. It will also create the ''manage.py'' script, which has more useful functions for managing and testing your project. For instance, django has a small test server built into ''manage.py''.
 
This will create the directory ''myproject'' under the current directory. It will also create the ''manage.py'' script, which has more useful functions for managing and testing your project. For instance, django has a small test server built into ''manage.py''.
 
<pre>
 
<pre>
$ python manage.py runserver
+
$ python2 manage.py runserver
 
Validating models...
 
Validating models...
 
0 errors found
 
0 errors found
Line 33: Line 33:
 
It can be changed to run at, say, port 8080 like so.
 
It can be changed to run at, say, port 8080 like so.
 
<pre>
 
<pre>
$ python manage.py runserver 8080
+
$ python2 manage.py runserver 8080
 
Validating models...
 
Validating models...
 
0 errors found
 
0 errors found

Revision as of 12:09, 22 January 2011

Django is a high-level Python Web framework that encourages rapid development and clean, pragmatic design.

Installation

Django can be installed through pacman by installing the 'django' package.

# pacman -S django

There is also an svn PKGBUILD available in the AUR, 'django-svn'. Using yaourt it can be installed as follows.

# yaourt -S django-svn

Of course, you can always download it directly from The Official Website

Usage

Django is not used like other python libraries for the most part, but it can. After installation, you should be able to simply import django in any python script.

>>> import django

In order to start a project, use django-admin.py.

$ django-admin.py startproject myproject

This will create the directory myproject under the current directory. It will also create the manage.py script, which has more useful functions for managing and testing your project. For instance, django has a small test server built into manage.py.

$ python2 manage.py runserver
Validating models...
0 errors found

Django version 1.1, using settings 'modsite.settings'
Development server is running at http://127.0.0.1:8000/
Quit the server with CONTROL-C.

It can be changed to run at, say, port 8080 like so.

$ python2 manage.py runserver 8080
Validating models...
0 errors found

Django version 1.1, using settings 'modsite.settings'
Development server is running at http://127.0.0.1:8080/
Quit the server with CONTROL-C.

For more help, please see the Django Book or Official Django Documentation