Changeset 1269
- Timestamp:
- 11/16/05 11:12:17 (3 years ago)
- Files:
-
- django/branches/new-admin/django/conf/app_template/views (deleted)
- django/branches/new-admin/django/conf/app_template/views.py (added)
- django/branches/new-admin/django/core/formfields.py (modified) (2 diffs)
- django/branches/new-admin/django/utils/translation.py (modified) (1 diff)
- django/branches/new-admin/docs/forms.txt (modified) (1 diff)
- django/branches/new-admin/docs/generic_views.txt (modified) (2 diffs)
- django/branches/new-admin/docs/install.txt (modified) (1 diff)
- django/branches/new-admin/docs/templates_python.txt (modified) (2 diffs)
- django/branches/new-admin/docs/tutorial01.txt (modified) (1 diff)
- django/branches/new-admin/docs/tutorial02.txt (modified) (1 diff)
- django/branches/new-admin/docs/tutorial03.txt (modified) (7 diffs)
- django/branches/new-admin/docs/tutorial04.txt (modified) (4 diffs)
- django/branches/new-admin/ez_setup.py (modified) (2 diffs)
- django/branches/new-admin/setup.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/branches/new-admin/django/core/formfields.py
r1255 r1269 103 103 self.error_dict = error_dict 104 104 self._inline_collections = None 105 self.fields = [self.__getitem__(field.field_name) for field in self.manipulator.fields]106 105 self.edit_inline = edit_inline 107 106 … … 134 133 def has_errors(self): 135 134 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) 136 144 137 145 class FormFieldWrapper: django/branches/new-admin/django/utils/translation.py
r1223 r1269 248 248 if _default is None: 249 249 from django.conf import settings 250 _default = translation( '*',settings.LANGUAGE_CODE)250 _default = translation(settings.LANGUAGE_CODE) 251 251 return _default.ngettext(singular, plural, number) 252 252 django/branches/new-admin/docs/forms.txt
r876 r1269 390 390 391 391 def contact_form(request): 392 manipulator = Contact FormManipulator()392 manipulator = ContactManipulator() 393 393 if request.POST: 394 394 new_data = request.POST.copy() django/branches/new-admin/docs/generic_views.txt
r1255 r1269 77 77 78 78 ``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 82 83 For example, given the following URL patterns:: 83 84 84 85 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'}), 87 88 ) 88 89 89 90 ... a request to ``/foo/`` would cause the ``foo_index`` template to be 90 91 rendered, and a request to ``/foo/15/`` would cause the ``foo_detail`` 91 92 template to be rendered with a context variable ``{{ params.id }}`` that is 92 93 set to ``15``. 93 94 94 95 ``redirect_to`` 95 96 Issue a redirect to a given URL. 96 97 97 The given url may contain dict-style string formattingwhich will be98 The given URL may contain dict-style string formatting, which will be 98 99 interpolated against the params in the URL. For example, to redirect from 99 100 ``/foo/<id>/`` to ``/bar/<id>/``, you could use the following urlpattern:: … … 102 103 ('^foo/(?p<id>\d+)/$', 'redirect_to', {'url' : '/bar/%(id)s/'}), 103 104 ) 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. 106 107 107 108 Using date-based generic views django/branches/new-admin/docs/install.txt
r1198 r1269 78 78 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 79 79 80 There IS no official version yet. But once there is, here's how it'll work: 80 1. Download Django-0.90.tar.gz from our `download page`_. 81 2. ``tar xzvf Django-0.90.tar.gz`` 82 3. ``cd Django-0.90`` 83 4. ``sudo python setup.py install`` 81 84 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`` 85 Note that the last command will automatically download and install setuptools_ 86 if you don't already have it installed. This requires a working Internet 87 connection. 88 89 This will install Django in your Python installation's ``site-packages`` 90 directory. 91 92 .. _setuptools: http://peak.telecommunity.com/DevCenter/setuptools 86 93 87 94 Installing the development version django/branches/new-admin/docs/templates_python.txt
r1125 r1269 247 247 * ``user`` -- An ``auth.User`` instance representing the currently 248 248 logged-in user (or an ``AnonymousUser`` instance, if the client isn't 249 logged in). 249 logged in). See the `user authentication docs`. 250 250 * ``messages`` -- A list of ``auth.Message`` objects for the currently 251 251 logged-in user. 252 252 * ``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`_. 254 255 255 256 Also, if your ``DEBUG`` setting is set to ``True``, every ``DjangoContext`` … … 280 281 * You'll have to be careful not to set the variable ``current_time`` when 281 282 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 282 286 283 287 Loading templates django/branches/new-admin/docs/tutorial01.txt
r966 r1269 132 132 __init__.py 133 133 polls.py 134 views/ 135 __init__.py 134 views.py 136 135 137 136 This directory structure will house the poll application. django/branches/new-admin/docs/tutorial02.txt
r966 r1269 82 82 :target: http://media.djangoproject.com/img/doc/tutorial/admin02.png 83 83 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.84 By default, you should see two types of editable content: groups and users. 85 These are core features Django ships with by default. 86 86 87 87 .. _"I can't log in" questions: http://www.djangoproject.com/documentation/faq/#the-admin-site django/branches/new-admin/docs/tutorial03.txt
r1223 r1269 74 74 75 75 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'), 80 80 ) 81 81 … … 85 85 and traverses the regular expressions in order. When it finds a regular 86 86 expression that matches -- ``r'^polls/(?P<poll_id>\d+)/$'`` -- it loads the 87 associated Python package/module: ``myproject.apps.polls.views. polls.detail``. That88 corresponds to the function ``detail()`` in ``myproject/apps/polls/views /polls.py``.87 associated Python package/module: ``myproject.apps.polls.views.detail``. That 88 corresponds to the function ``detail()`` in ``myproject/apps/polls/views.py``. 89 89 Finally, it calls that ``detail()`` function like so:: 90 90 … … 100 100 something like this:: 101 101 102 (r'^polls/latest\.php$', 'myproject.apps.polls.views. polls.index'),103 104 But, don't do that. It's s tupid.102 (r'^polls/latest\.php$', 'myproject.apps.polls.views.index'), 103 104 But, don't do that. It's silly. 105 105 106 106 If you need help with regular expressions, see `Wikipedia's entry`_ and the … … 126 126 127 127 Now 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 128 You 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 135 This error happened because you haven't written a function ``index()`` in the 136 module ``myproject/apps/polls/views.py``. 132 137 133 138 Try "/polls/23/", "/polls/23/results/" and "/polls/23/vote/". The error 134 messages should tell you which view Django tried (and failed to find, because135 youhaven't written any views yet).136 137 Time to write the first view. Create the file ``myproject/apps/polls/views/polls.py``139 messages tell you which view Django tried (and failed to find, because you 140 haven't written any views yet). 141 142 Time to write the first view. Open the file ``myproject/apps/polls/views.py`` 138 143 and put the following Python code in it:: 139 144 … … 375 380 376 381 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'), 381 386 ) 382 387 383 Namely, ``myproject.apps.polls.views .polls`` is in every callback.388 Namely, ``myproject.apps.polls.views`` is in every callback. 384 389 385 390 Because this is a common case, the URLconf framework provides a shortcut for … … 387 392 first argument to ``patterns()``, like so:: 388 393 389 urlpatterns = patterns('myproject.apps.polls.views .polls',394 urlpatterns = patterns('myproject.apps.polls.views', 390 395 (r'^polls/$', 'index'), 391 396 (r'^polls/(?P<poll_id>\d+)/$', 'detail'), … … 436 441 line:: 437 442 438 urlpatterns = patterns('myproject.apps.polls.views .polls',443 urlpatterns = patterns('myproject.apps.polls.views', 439 444 (r'^$', 'index'), 440 445 (r'^(?P<poll_id>\d+)/$', 'detail'), django/branches/new-admin/docs/tutorial04.txt
r1041 r1269 45 45 included this line:: 46 46 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 49 So let's create a ``vote()`` function in ``myproject/apps/polls/views.py``:: 50 50 51 51 from django.core.extensions import get_object_or_404, render_to_response … … 159 159 from django.conf.urls.defaults import * 160 160 161 urlpatterns = patterns('myproject.apps.polls.views .polls',161 urlpatterns = patterns('myproject.apps.polls.views', 162 162 (r'^$', 'index'), 163 163 (r'^(?P<poll_id>\d+)/$', 'detail'), … … 179 179 (r'^(?P<object_id>\d+)/$', 'django.views.generic.list_detail.object_detail', info_dict), 180 180 (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'), 182 182 ) 183 183 … … 218 218 219 219 Finally, you can delete the ``index()``, ``detail()`` and ``results()`` views 220 from ``polls/views /polls.py``. We don't need them anymore.220 from ``polls/views.py``. We don't need them anymore. 221 221 222 222 For full details on generic views, see the `generic views documentation`_. django/branches/new-admin/ez_setup.py
r877 r1269 15 15 """ 16 16 import sys 17 DEFAULT_VERSION = "0.6a 5"17 DEFAULT_VERSION = "0.6a7" 18 18 DEFAULT_URL = "http://cheeseshop.python.org/packages/%s/s/setuptools/" % sys.version[:3] 19 19 … … 31 31 'setuptools-0.6a5-py2.3.egg': '748408389c49bcd2d84f6ae0b01695b1', 32 32 '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', 33 37 } 34 38 django/branches/new-admin/setup.py
r1040 r1269 5 5 6 6 setup( 7 name = " django",8 version = " 1.0.0",7 name = "Django", 8 version = "0.90", 9 9 url = 'http://www.djangoproject.com/', 10 10 author = 'Lawrence Journal-World', … … 14 14 packages = find_packages(), 15 15 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', 17 37 'templates/admin_doc/*.html', 18 38 'templates/registration/*.html',
