Django

Code

Changeset 1269

Show
Ignore:
Timestamp:
11/16/05 11:12:17 (3 years ago)
Author:
rjwittams
Message:

mergeed to trunk r1266

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/branches/new-admin/django/core/formfields.py

    r1255 r1269  
    103103        self.error_dict = error_dict 
    104104        self._inline_collections = None 
    105         self.fields = [self.__getitem__(field.field_name) for field in self.manipulator.fields] 
    106105        self.edit_inline = edit_inline 
    107106     
     
    134133    def has_errors(self): 
    135134        return self.error_dict != {} 
     135 
     136    def _get_fields(self): 
     137        try: 
     138            return self._fields 
     139        except AttributeError: 
     140            self._fields = [self.__getitem__(field.field_name) for field in self.manipulator.fields] 
     141            return self._fields 
     142 
     143    fields = property(_get_fields) 
    136144 
    137145class FormFieldWrapper: 
  • django/branches/new-admin/django/utils/translation.py

    r1223 r1269  
    248248    if _default is None: 
    249249        from django.conf import settings 
    250         _default = translation('*', settings.LANGUAGE_CODE) 
     250        _default = translation(settings.LANGUAGE_CODE) 
    251251    return _default.ngettext(singular, plural, number) 
    252252 
  • django/branches/new-admin/docs/forms.txt

    r876 r1269  
    390390 
    391391    def contact_form(request): 
    392         manipulator = ContactFormManipulator() 
     392        manipulator = ContactManipulator() 
    393393        if request.POST: 
    394394            new_data = request.POST.copy() 
  • django/branches/new-admin/docs/generic_views.txt

    r1255 r1269  
    7777 
    7878``direct_to_template`` 
    79     Renders a given template using any extra parameters passed in the 
    80     urlpattern; requires the ``template`` argument. 
    81      
     79    Renders a given template, passing it a ``{{ params }}`` template variable, 
     80    which is a dictionary of the parameters captured in the URL. This requires 
     81    the ``template`` argument. 
     82 
    8283    For example, given the following URL patterns:: 
    83          
     84 
    8485        urlpatterns = patterns('django.views.generic.simple', 
    85             (r'^foo/$',             'direct_to_template', {'template' : 'foo_index'}), 
    86             (r'^foo/(?P<id>\d+)/$', 'direct_to_template', {'template' : 'foo_detail'}), 
     86            (r'^foo/$',             'direct_to_template', {'template': 'foo_index'}), 
     87            (r'^foo/(?P<id>\d+)/$', 'direct_to_template', {'template': 'foo_detail'}), 
    8788        ) 
    88          
     89 
    8990    ... a request to ``/foo/`` would cause the ``foo_index`` template to be 
    9091    rendered, and a request to ``/foo/15/`` would cause the ``foo_detail`` 
    9192    template to be rendered with a context variable ``{{ params.id }}`` that is 
    9293    set to ``15``. 
    93      
     94 
    9495``redirect_to`` 
    9596    Issue a redirect to a given URL. 
    9697 
    97     The given url may contain dict-style string formatting which will be 
     98    The given URL may contain dict-style string formatting, which will be 
    9899    interpolated against the params in the URL.  For example, to redirect from 
    99100    ``/foo/<id>/`` to ``/bar/<id>/``, you could use the following urlpattern:: 
     
    102103            ('^foo/(?p<id>\d+)/$', 'redirect_to', {'url' : '/bar/%(id)s/'}), 
    103104        ) 
    104          
    105     If the given url is ``None``, a HttpResponseGone (410) will be issued. 
     105 
     106    If the given URL is ``None``, an ``HttpResponseGone`` (410) will be issued. 
    106107 
    107108Using date-based generic views 
  • django/branches/new-admin/docs/install.txt

    r1198 r1269  
    7878~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    7979 
    80 There IS no official version yet. But once there is, here's how it'll work: 
     801. Download Django-0.90.tar.gz from our `download page`_. 
     812. ``tar xzvf Django-0.90.tar.gz`` 
     823. ``cd Django-0.90`` 
     834. ``sudo python setup.py install`` 
    8184 
    82 1. Download the tarball of the latest official version from our `download page`_. 
    83 2. ``tar xzvf django-1.0.0.tar.gz`` 
    84 3. ``cd django-1.0.0`` 
    85 4. ``python setup.py install`` 
     85Note that the last command will automatically download and install setuptools_ 
     86if you don't already have it installed. This requires a working Internet 
     87connection. 
     88 
     89This will install Django in your Python installation's ``site-packages`` 
     90directory. 
     91 
     92.. _setuptools: http://peak.telecommunity.com/DevCenter/setuptools 
    8693 
    8794Installing the development version 
  • django/branches/new-admin/docs/templates_python.txt

    r1125 r1269  
    247247    * ``user`` -- An ``auth.User`` instance representing the currently 
    248248      logged-in user (or an ``AnonymousUser`` instance, if the client isn't 
    249       logged in). 
     249      logged in). See the `user authentication docs`. 
    250250    * ``messages`` -- A list of ``auth.Message`` objects for the currently 
    251251      logged-in user. 
    252252    * ``perms`` -- An instance of ``django.core.extensions.PermWrapper``, 
    253       representing the permissions that the currently logged-in user has. 
     253      representing the permissions that the currently logged-in user has. See 
     254      the `permissions docs`_. 
    254255 
    255256Also, if your ``DEBUG`` setting is set to ``True``, every ``DjangoContext`` 
     
    280281    * You'll have to be careful not to set the variable ``current_time`` when 
    281282      you populate this context. If you do, you'll override the other one. 
     283 
     284.. _user authentication docs: http://www.djangoproject.com/documentation/models/authentication/#users 
     285.. _permissions docs: http://www.djangoproject.com/documentation/models/authentication/#permissions 
    282286 
    283287Loading templates 
  • django/branches/new-admin/docs/tutorial01.txt

    r966 r1269  
    132132            __init__.py 
    133133            polls.py 
    134         views/ 
    135             __init__.py 
     134        views.py 
    136135 
    137136This directory structure will house the poll application. 
  • django/branches/new-admin/docs/tutorial02.txt

    r966 r1269  
    8282   :target: http://media.djangoproject.com/img/doc/tutorial/admin02.png 
    8383 
    84 By default, you should see four types of editable content: groups, users, 
    85 redirects and flat pages. These are core features Django ships with by default. 
     84By default, you should see two types of editable content: groups and users. 
     85These are core features Django ships with by default. 
    8686 
    8787.. _"I can't log in" questions: http://www.djangoproject.com/documentation/faq/#the-admin-site 
  • django/branches/new-admin/docs/tutorial03.txt

    r1223 r1269  
    7474 
    7575    urlpatterns = patterns('', 
    76         (r'^polls/$', 'myproject.apps.polls.views.polls.index'), 
    77         (r'^polls/(?P<poll_id>\d+)/$', 'myproject.apps.polls.views.polls.detail'), 
    78         (r'^polls/(?P<poll_id>\d+)/results/$', 'myproject.apps.polls.views.polls.results'), 
    79         (r'^polls/(?P<poll_id>\d+)/vote/$', 'myproject.apps.polls.views.polls.vote'), 
     76        (r'^polls/$', 'myproject.apps.polls.views.index'), 
     77        (r'^polls/(?P<poll_id>\d+)/$', 'myproject.apps.polls.views.detail'), 
     78        (r'^polls/(?P<poll_id>\d+)/results/$', 'myproject.apps.polls.views.results'), 
     79        (r'^polls/(?P<poll_id>\d+)/vote/$', 'myproject.apps.polls.views.vote'), 
    8080    ) 
    8181 
     
    8585and traverses the regular expressions in order. When it finds a regular 
    8686expression that matches -- ``r'^polls/(?P<poll_id>\d+)/$'`` -- it loads the 
    87 associated Python package/module: ``myproject.apps.polls.views.polls.detail``. That 
    88 corresponds to the function ``detail()`` in ``myproject/apps/polls/views/polls.py``. 
     87associated Python package/module: ``myproject.apps.polls.views.detail``. That 
     88corresponds to the function ``detail()`` in ``myproject/apps/polls/views.py``. 
    8989Finally, it calls that ``detail()`` function like so:: 
    9090 
     
    100100something like this:: 
    101101 
    102     (r'^polls/latest\.php$', 'myproject.apps.polls.views.polls.index'), 
    103  
    104 But, don't do that. It's stupid
     102    (r'^polls/latest\.php$', 'myproject.apps.polls.views.index'), 
     103 
     104But, don't do that. It's silly
    105105 
    106106If you need help with regular expressions, see `Wikipedia's entry`_ and the 
     
    126126 
    127127Now go to "http://localhost:8000/polls/" on your domain in your Web browser. 
    128 You should get a Python traceback with the following error message:: 
    129  
    130     ViewDoesNotExist: Could not import myproject.apps.polls.views.polls. Error 
    131     was: No module named polls 
     128You should get a pleasantly-colored error page with the following message:: 
     129 
     130    ViewDoesNotExist at /polls/ 
     131 
     132    Tried index in module myproject.apps.polls.views. Error was: 'module' 
     133    object has no attribute 'index' 
     134 
     135This error happened because you haven't written a function ``index()`` in the 
     136module ``myproject/apps/polls/views.py``. 
    132137 
    133138Try "/polls/23/", "/polls/23/results/" and "/polls/23/vote/". The error 
    134 messages should tell you which view Django tried (and failed to find, because 
    135 you haven't written any views yet). 
    136  
    137 Time to write the first view. Create the file ``myproject/apps/polls/views/polls.py`` 
     139messages tell you which view Django tried (and failed to find, because you 
     140haven't written any views yet). 
     141 
     142Time to write the first view. Open the file ``myproject/apps/polls/views.py`` 
    138143and put the following Python code in it:: 
    139144 
     
    375380 
    376381    urlpatterns = patterns('', 
    377         (r'^polls/$', 'myproject.apps.polls.views.polls.index'), 
    378         (r'^polls/(?P<poll_id>\d+)/$', 'myproject.apps.polls.views.polls.detail'), 
    379         (r'^polls/(?P<poll_id>\d+)/results/$', 'myproject.apps.polls.views.polls.results'), 
    380         (r'^polls/(?P<poll_id>\d+)/vote/$', 'myproject.apps.polls.views.polls.vote'), 
     382        (r'^polls/$', 'myproject.apps.polls.views.index'), 
     383        (r'^polls/(?P<poll_id>\d+)/$', 'myproject.apps.polls.views.detail'), 
     384        (r'^polls/(?P<poll_id>\d+)/results/$', 'myproject.apps.polls.views.results'), 
     385        (r'^polls/(?P<poll_id>\d+)/vote/$', 'myproject.apps.polls.views.vote'), 
    381386    ) 
    382387 
    383 Namely, ``myproject.apps.polls.views.polls`` is in every callback. 
     388Namely, ``myproject.apps.polls.views`` is in every callback. 
    384389 
    385390Because this is a common case, the URLconf framework provides a shortcut for 
     
    387392first argument to ``patterns()``, like so:: 
    388393 
    389     urlpatterns = patterns('myproject.apps.polls.views.polls', 
     394    urlpatterns = patterns('myproject.apps.polls.views', 
    390395        (r'^polls/$', 'index'), 
    391396        (r'^polls/(?P<poll_id>\d+)/$', 'detail'), 
     
    436441line:: 
    437442 
    438     urlpatterns = patterns('myproject.apps.polls.views.polls', 
     443    urlpatterns = patterns('myproject.apps.polls.views', 
    439444        (r'^$', 'index'), 
    440445        (r'^(?P<poll_id>\d+)/$', 'detail'), 
  • django/branches/new-admin/docs/tutorial04.txt

    r1041 r1269  
    4545included this line:: 
    4646 
    47     (r'^polls/(?P<poll_id>\d+)/vote/$', 'myproject.apps.polls.views.polls.vote'), 
    48  
    49 So let's create a ``vote()`` function in ``myproject/apps/polls/views/polls.py``:: 
     47    (r'^polls/(?P<poll_id>\d+)/vote/$', 'myproject.apps.polls.views.vote'), 
     48 
     49So let's create a ``vote()`` function in ``myproject/apps/polls/views.py``:: 
    5050 
    5151    from django.core.extensions import get_object_or_404, render_to_response 
     
    159159    from django.conf.urls.defaults import * 
    160160 
    161     urlpatterns = patterns('myproject.apps.polls.views.polls', 
     161    urlpatterns = patterns('myproject.apps.polls.views', 
    162162        (r'^$', 'index'), 
    163163        (r'^(?P<poll_id>\d+)/$', 'detail'), 
     
    179179        (r'^(?P<object_id>\d+)/$', 'django.views.generic.list_detail.object_detail', info_dict), 
    180180        (r'^(?P<object_id>\d+)/results/$', 'django.views.generic.list_detail.object_detail', dict(info_dict, template_name='polls/results')), 
    181         (r'^(?P<poll_id>\d+)/vote/$', 'myproject.apps.polls.views.polls.vote'), 
     181        (r'^(?P<poll_id>\d+)/vote/$', 'myproject.apps.polls.views.vote'), 
    182182    ) 
    183183 
     
    218218 
    219219Finally, you can delete the ``index()``, ``detail()`` and ``results()`` views 
    220 from ``polls/views/polls.py``. We don't need them anymore. 
     220from ``polls/views.py``. We don't need them anymore. 
    221221 
    222222For full details on generic views, see the `generic views documentation`_. 
  • django/branches/new-admin/ez_setup.py

    r877 r1269  
    1515""" 
    1616import sys 
    17 DEFAULT_VERSION = "0.6a5
     17DEFAULT_VERSION = "0.6a7
    1818DEFAULT_URL     = "http://cheeseshop.python.org/packages/%s/s/setuptools/" % sys.version[:3] 
    1919 
     
    3131    'setuptools-0.6a5-py2.3.egg': '748408389c49bcd2d84f6ae0b01695b1', 
    3232    'setuptools-0.6a5-py2.4.egg': '999bacde623f4284bfb3ea77941d2627', 
     33    'setuptools-0.6a6-py2.3.egg': '7858139f06ed0600b0d9383f36aca24c', 
     34    'setuptools-0.6a6-py2.4.egg': 'c10d20d29acebce0dc76219dc578d058', 
     35    'setuptools-0.6a7-py2.3.egg': 'cfc4125ddb95c07f9500adc5d6abef6f', 
     36    'setuptools-0.6a7-py2.4.egg': 'c6d62dab4461f71aed943caea89e6f20', 
    3337} 
    3438 
  • django/branches/new-admin/setup.py

    r1040 r1269  
    55 
    66setup( 
    7     name = "django", 
    8     version = "1.0.0", 
     7    name = "Django", 
     8    version = "0.90", 
    99    url = 'http://www.djangoproject.com/', 
    1010    author = 'Lawrence Journal-World', 
     
    1414    packages = find_packages(), 
    1515    package_data = { 
    16         'django.contrib.admin': ['templates/admin/*.html',  
     16        '': ['*.TXT'], 
     17        'django.conf': ['locale/bn/LC_MESSAGES/*', 
     18                        'locale/cs/LC_MESSAGES/*', 
     19                        'locale/cy/LC_MESSAGES/*', 
     20                        'locale/da/LC_MESSAGES/*', 
     21                        'locale/de/LC_MESSAGES/*', 
     22                        'locale/en/LC_MESSAGES/*', 
     23                        'locale/es/LC_MESSAGES/*', 
     24                        'locale/fr/LC_MESSAGES/*', 
     25                        'locale/gl/LC_MESSAGES/*', 
     26                        'locale/is/LC_MESSAGES/*', 
     27                        'locale/it/LC_MESSAGES/*', 
     28                        'locale/no/LC_MESSAGES/*', 
     29                        'locale/pt_BR/LC_MESSAGES/*', 
     30                        'locale/ro/LC_MESSAGES/*', 
     31                        'locale/ru/LC_MESSAGES/*', 
     32                        'locale/sk/LC_MESSAGES/*', 
     33                        'locale/sr/LC_MESSAGES/*', 
     34                        'locale/sv/LC_MESSAGES/*', 
     35                        'locale/zh_CN/LC_MESSAGES/*'], 
     36         'django.contrib.admin':['templates/admin/*.html',  
    1737                                 'templates/admin_doc/*.html', 
    1838                                 'templates/registration/*.html',