Django

Code

Changeset 187

Show
Ignore:
Timestamp:
07/18/05 18:14:48 (3 years ago)
Author:
adrian
Message:

Changed tutorial2 to use 'django-admin runserver' instead of mod_python. Also updated WSGI mentions in the docs, now that we're WSGI-friendly.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/docs/faq.txt

    r133 r187  
    2121.. _Python: http://www.python.org/ 
    2222.. _PostgreSQL: http://www.postgresql.org/ 
    23  
    2423 
    2524What does "Django" mean, and how do you pronounce it? 
     
    9897----------------------------------------------------------------------------------------------------------------------------------------------------- 
    9998 
    100 That's because Django isn't strictly a MVC framework. We don't really believe in 
    101 any capital-M Methodologies; we do what "feels" right. If you squint the right 
     99That's because Django isn't strictly a MVC framework. We don't really believe in 
     100any capital-M Methodologies; we do what "feels" right. If you squint the right 
    102101way, you can call Django's ORM the "Model", the view functions the "View", and 
    103102the dynamically-generated API the "Controller" -- but not really. 
     
    110109--------------------------------------------------- 
    111110 
    112 They're in the works. It's amazing how much time those things take! Stay tuned... 
     111They're in the works. It's amazing how much time those things take! Stay tuned... 
    113112 
    114113Installation questions 
     
    121120    #. Install Django (read the `installation guide`_). 
    122121    #. Walk through the tutorial_. 
    123     #. Check out the rest of the documentation_, and ask questions if you 
     122    #. Check out the rest of the documentation_, and `ask questions`_ if you 
    124123       run into trouble. 
    125124 
     
    128127.. _tutorial:  http://www.djangoproject.com/documentation/tutorial1/ 
    129128.. _documentation: http://www.djangoproject.com/documentation/ 
     129.. _ask questions: http://www.djangoproject.com/community/ 
    130130 
    131131How do I fix the "install a later version of setuptools" error? 
     
    137137-------------------------------- 
    138138 
    139 Django requires Python_ 2.3 or later, `Apache 2`_, and mod_python_. 
     139Django requires Python_ 2.3 or later. 
     140 
     141For a development environment -- if you just want to experiment with Django -- 
     142you don't need to have a separate Web server installed; Django comes with its 
     143own lightweight development server. For a production environment, we recommend 
     144`Apache 2`_ and mod_python_, although Django follows the WSGI_ spec, which 
     145means it can run on a variety of server platforms. 
    140146 
    141147You'll also need a database engine. PostgreSQL_ is recommended, and MySQL_ is 
     
    145151.. _Apache 2: http://httpd.apache.org/ 
    146152.. _mod_python: http://www.modpython.org/ 
     153.. _WSGI: http://www.python.org/peps/pep-0333.html 
    147154.. _PostgreSQL: http://www.postgresql.org/ 
    148155.. _MySQL: http://www.mysql.com/ 
    149156 
     157Do I have to use mod_python? 
     158---------------------------- 
     159 
     160Not if you just want to play around and develop things on your local computer. 
     161Django comes with its own Web server, and things should Just Work. 
     162 
     163For production use, though, we recommend mod_python. The Django developers have 
     164been running it on mod_python for about two years, and it's quite stable. 
     165 
     166However, if you don't want to use mod_python, you can use a different server, 
     167as long as that server has WSGI_ hooks. More information on alternate server 
     168arrangements is forthcoming. 
     169 
     170.. _WSGI: http://www.python.org/peps/pep-0333.html 
     171 
    150172How do I install mod_python on Windows? 
    151173--------------------------------------- 
    152174 
    153     * If you are running Python 2.4, check out this `guide to mod_python & Python 2.3`_. 
    154  
    155     * For Python 2.3, grab mod_python from http://www.mod_python.org/, the read 
    156       `Running mod_python on Apache on Windows2000`_. 
    157  
    158     * Also try this (not Windows-specific) `guide to getting mod_python working`_. 
     175* For Python 2.4, check out this `guide to mod_python & Python 2.3`_. 
     176* For Python 2.3, grab mod_python from http://www.mod_python.org/ and read 
     177  `Running mod_python on Apache on Windows2000`_. 
     178* Also, try this (not Windows-specific) `guide to getting mod_python working`_. 
    159179 
    160180.. _`guide to mod_python & Python 2.3`: http://www.lehuen.com/nicolas/index.php/2005/02/21/39-win32-build-of-mod_python-314-for-python-24 
     
    164184(Thanks to deelan for this info.) 
    165185 
    166 Do I have to use mod_python? 
    167 ---------------------------- 
    168  
    169 In the first release, yes. However, WSGI_ support (which will let Django run 
    170 under FCGI, SCGI, medusa, etc.) is in the works. Stay tuned! 
    171  
    172 .. _WSGI: http://www.python.org/peps/pep-0333.html 
    173  
    174186Will Django run under shared hosting (like TextDrive or Dreamhost)? 
    175187------------------------------------------------------------------- 
    176188 
    177189Right now, no, unless you can get your host to install mod_python. However, as 
    178 the previous answer says, WSGI support is coming! 
     190the community starts to use Django's WSGI bindings with other Web servers, this 
     191will probably be possible sooner rather than later. 
    179192 
    180193Using Django 
     
    245258 
    246259.. _`guide to the CSS used in the admin`: http://www.djangoproject.com/documentation/admin_css/ 
    247  
  • django/trunk/docs/install.txt

    r177 r187  
    88============================= 
    99 
    10 Currently, Django runs on Apache_ with `mod_python`_. mod_python is similar to 
    11 mod_perl -- it embeds Python within Apache and loads Python code into memory 
    12 when the server starts. Code stays in memory throughout the life of an Apache 
    13 process, which leads to significant performance gains over CGI. 
     10If you just want to experiment with Django, skip this step. Django comes with 
     11its own Web server for development purposes. 
    1412 
    15 If you can't use mod_python for some reason, fear not: We're planning full WSGI_ 
    16 support, which means Django will run on a variety of server platforms. 
     13If you want to use Django on a production site, use Apache with `mod_python`_. 
     14mod_python is similar to mod_perl -- it embeds Python within Apache and loads 
     15Python code into memory when the server starts. Code stays in memory throughout 
     16the life of an Apache process, which leads to significant performance gains 
     17over other server arrangements. Make sure you have Apache installed, with the 
     18mod_python module activated. 
    1719 
    18 For the time being, make sure you have Apache installed, with the mod_python 
    19 module activated. 
     20If you can't use mod_python for some reason, fear not: Django follows the WSGI_ 
     21spec, which allows it to run on a variety of server platforms. As people 
     22experiment with different server platforms, we'll update this document to 
     23give specific installation instructions for each platform. 
    2024 
    2125.. _Apache: http://httpd.apache.org/ 
  • django/trunk/docs/tutorial02.txt

    r183 r187  
    2626managers. 
    2727 
    28 Expose the admin media files 
     28Start the development server 
    2929============================ 
    3030 
    31 Django's admin is intended to be fully functional and good looking. For that 
    32 reason, Django ships with admin media files -- CSS, JavaScript and images -- 
    33 that comprise the admin's design. To set up a Django admin instance, the first 
    34 thing to do is put those media files online somewhere. 
    35  
    36 (Note: Although Django ships with a default design for its admin site, you can 
    37 change it however you'd like. The admin uses Django's own template system and 
    38 is powered -- surprise, surprise -- by Django itself, so it is completely 
    39 customizable.) 
    40  
    41 The files are in the ``media`` directory of the Django distribution. To 
    42 "activate" them, copy that directory under a Web document root somewhere, so 
    43 that you can access them via the Web. 
    44  
    45 Be careful not to put your Python source code under the Web document root. Just 
    46 do the media files. 
    47  
    48 Then, tell Django where you put them, via ``ADMIN_MEDIA_PREFIX`` in the 
    49 ``myproject.settings.admin`` settings file. Examples:: 
    50  
    51     # You can leave off the domain if they're on the same domain as your admin 
    52     # site will be. 
    53     ADMIN_MEDIA_PREFIX = '/adminmedia/' 
    54  
    55     # Otherwise, use the fully-qualified domain. 
    56     ADMIN_MEDIA_PREFIX = 'http://www.foo.com/adminmedia/' 
    57  
    58 Make sure to include a trailing slash. 
    59  
    60 Hook into mod_python 
    61 ==================== 
    62  
    63 Now let's take the opportunity to hook Django into Apache/mod_python. Edit your 
    64 ``httpd.conf`` file and add this:: 
    65  
    66     <Location "/admin/"> 
    67         SetHandler python-program 
    68         PythonHandler django.core.handlers.modpython 
    69         SetEnv DJANGO_SETTINGS_MODULE myproject.settings.admin 
    70         PythonDebug On 
    71     </Location> 
    72  
    73 This tells Apache: "Use mod_python for any URL at or under '/admin/', using the 
    74 Django mod_python handler." It also passes the value of ``DJANGO_SETTINGS_MODULE``, 
    75 so mod_python knows which project to use. Note that we're passing the path to 
    76 the ``admin`` settings, not the ``main`` settings. That's because this is the 
    77 admin site, which has slightly different settings. 
    78  
    79 Also, if you've manually altered your ``PYTHONPATH`` to put your project on it, 
    80 you'll need to tell mod_python:: 
    81  
    82     PythonPath "['/path/to/project'] + sys.path" 
    83  
    84 You can also add directives such as ``PythonAutoReload Off`` for performance. 
    85 See the `mod_python documentation`_ for a full list of options. 
    86  
    87 When you've done that, restart Apache and go to /admin/ on your domain. You 
    88 should see the admin's login screen: 
     31To make things easy, Django comes with a pure-Python Web server that builds on 
     32the BaseHTTPServer included in Python's standard library. Let's start the 
     33server and explore the admin site. First, set the ``DJANGO_SETTINGS_MODULE`` 
     34environment variable to the location of your admin settings:: 
     35 
     36    export DJANGO_SETTINGS_MODULE=myproject.settings.admin 
     37 
     38Then, run this command to start the server:: 
     39 
     40    django-admin.py runserver 
     41 
     42It'll start a Web server running locally -- on port 8000, by default. If you 
     43want to change the server's port, pass it as a command-line argument:: 
     44 
     45    django-admin.py runserver 8080 
     46 
     47Now, open a Web browser and go to "/admin/" on your domain. You should see the 
     48admin's login screen: 
    8949 
    9050.. image:: http://media.djangoproject.com/img/doc/tutorial/admin01.png 
    9151   :alt: Django admin login screen 
    9252 
    93 .. _mod_python documentation: http://modpython.org/live/current/doc-html/directives.html 
    94  
    9553Create a user account 
    9654===================== 
    9755 
    98 We can't log in, though, because we haven't created an admin user account yet. 
    99 Drop into the Python interactive interpreter and type this:: 
     56You can't log in, though, because you haven't created an admin user account 
     57yet. Drop into the Python interactive interpreter and type this:: 
    10058 
    10159    # The function django.models.auth.users.create_user() creates a new user 
     
    152110        ) 
    153111 
    154 Reload the Django admin index page. Note that you might have to restart Apache, 
    155 depending on your Apache settings. Because mod_python saves code in memory for 
    156 performance, Python code changes generally aren't reflected until Apache 
    157 restarts. One way around this is to set ``MaxRequestsPerChild 1`` in your 
    158 httpd.conf to force Apache to reload everything for each request. But don't do 
    159 that on a production server, or we'll revoke your Django privileges. 
     112Restart your development Web server, and reload the Django admin page. You'll 
     113have to restart the server each time you make a change to Python code -- but 
     114we're working on changing that. 
    160115 
    161116Explore the free admin functionality