Changeset 913
- Timestamp:
- 10/17/05 14:03:16 (3 years ago)
- Files:
-
- django/branches/new-admin/django/conf/admin_templates/changelist_generic.html (deleted)
- django/branches/new-admin/django/conf/global_settings.py (modified) (2 diffs)
- django/branches/new-admin/django/conf/project_template/settings/main.py (modified) (1 diff)
- django/branches/new-admin/django/core/template/loaders/app_directories.py (copied) (copied from django/trunk/django/core/template/loaders/app_directories.py) (1 diff)
- django/branches/new-admin/django/core/template/loaders/eggs.py (modified) (2 diffs)
- django/branches/new-admin/django/core/template/loaders/filesystem.py (modified) (1 diff)
- django/branches/new-admin/django/views/defaults.py (modified) (2 diffs)
- django/branches/new-admin/docs/design_philosophies.txt (modified) (1 diff)
- django/branches/new-admin/docs/django-admin.txt (modified) (1 diff)
- django/branches/new-admin/docs/model-api.txt (modified) (1 diff)
- django/branches/new-admin/docs/settings.txt (copied) (copied from django/trunk/docs/settings.txt)
- django/branches/new-admin/docs/templates_python.txt (modified) (2 diffs)
- django/branches/new-admin/docs/templates.txt (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/branches/new-admin/django/conf/global_settings.py
r881 r913 66 66 # documentation. 67 67 TEMPLATE_LOADERS = ( 68 # 'django.core.template.loaders.app_directories.load_template_source', 68 69 'django.core.template.loaders.filesystem.load_template_source', 69 70 # 'django.core.template.loaders.eggs.load_template_source', … … 110 111 # settings modules (in the format 'foo.bar.baz') for which this admin 111 112 # is an admin. 112 ADMIN_FOR = []113 ADMIN_FOR = () 113 114 114 115 # Whether to check the flat-pages table as a last resort for all 404 errors. django/branches/new-admin/django/conf/project_template/settings/main.py
r881 r913 31 31 SECRET_KEY = '' 32 32 33 # List of callables that know how to import templates from various sources. 34 TEMPLATE_LOADERS = ( 35 # 'django.core.template.loaders.app_directories.load_template_source', 36 'django.core.template.loaders.filesystem.load_template_source', 37 # 'django.core.template.loaders.eggs.load_template_source', 38 ) 39 33 40 MIDDLEWARE_CLASSES = ( 34 41 "django.middleware.common.CommonMiddleware", django/branches/new-admin/django/core/template/loaders/app_directories.py
r892 r913 22 22 filepath = os.path.join(template_dir, template_name) + TEMPLATE_FILE_EXTENSION 23 23 try: 24 return open(filepath).read()24 return (open(filepath).read(), filepath) 25 25 except IOError: 26 26 pass django/branches/new-admin/django/core/template/loaders/eggs.py
r876 r913 9 9 from django.conf.settings import INSTALLED_APPS, TEMPLATE_FILE_EXTENSION 10 10 11 def load_template_source( name,dirs=None):11 def load_template_source(template_name, template_dirs=None): 12 12 """ 13 13 Loads templates from Python eggs via pkg_resource.resource_string. 14 14 15 For every installed app, it tries to get the resource (app, name).15 For every installed app, it tries to get the resource (app, template_name). 16 16 """ 17 17 if resource_string is not None: 18 pkg_name = 'templates/' + name + TEMPLATE_FILE_EXTENSION18 pkg_name = 'templates/' + template_name + TEMPLATE_FILE_EXTENSION 19 19 for app in INSTALLED_APPS: 20 20 try: … … 22 22 except: 23 23 pass 24 raise TemplateDoesNotExist, name24 raise TemplateDoesNotExist, template_name 25 25 load_template_source.is_usable = resource_string is not None django/branches/new-admin/django/core/template/loaders/filesystem.py
r876 r913 18 18 error_msg = "Tried %s" % tried 19 19 else: 20 error_msg = "Your TEMPLATE_DIRS setting sis empty. Change it to point to at least one template directory."20 error_msg = "Your TEMPLATE_DIRS setting is empty. Change it to point to at least one template directory." 21 21 raise TemplateDoesNotExist, error_msg 22 22 load_template_source.is_usable = True django/branches/new-admin/django/views/defaults.py
r876 r913 11 11 except ObjectDoesNotExist: 12 12 raise Http404, "Content type %s object %s doesn't exist" % (content_type_id, object_id) 13 if not hasattr(obj, 'get_absolute_url'): 13 try: 14 absurl = obj.get_absolute_url() 15 except AttributeError: 14 16 raise Http404, "%s objects don't have get_absolute_url() methods" % content_type.name 17 if absurl.startswith('http://'): 18 return httpwrappers.HttpResponseRedirect(absurl) 15 19 object_domain = None 16 20 if hasattr(obj, 'get_site_list'): … … 28 32 pass 29 33 if not object_domain: 30 return httpwrappers.HttpResponseRedirect( obj.get_absolute_url())31 return httpwrappers.HttpResponseRedirect('http://%s%s' % (object_domain, obj.get_absolute_url()))34 return httpwrappers.HttpResponseRedirect(absurl) 35 return httpwrappers.HttpResponseRedirect('http://%s%s' % (object_domain, absurl)) 32 36 33 37 def page_not_found(request): django/branches/new-admin/docs/design_philosophies.txt
r864 r913 243 243 A view shouldn't care about which template system the developer uses -- or even 244 244 whether a template system is used at all. 245 246 Designate between GET and POST 247 ------------------------------ 248 249 GET and POST are distinct; developers should explicitly use one or the other. 250 The framework should make it easy to distinguish between GET and POST data. django/branches/new-admin/docs/django-admin.txt
r803 r913 113 113 Just execute ``django-admin.py runserver`` more than once. 114 114 115 Note that the default IP address, 127.0.0.1, is not accessible from other 116 machines on your network. To make your development server viewable to other 117 machines on the network, use its own IP address (e.g. ``192.168.2.1``) or 118 ``0.0.0.0``. 119 115 120 Examples: 116 121 ~~~~~~~~~ django/branches/new-admin/docs/model-api.txt
r854 r913 253 253 steps: 254 254 255 1. In your settings file, you'll need to define ``MEDIA_ROOT`` as the255 1. In your settings file, you'll need to define ``MEDIA_ROOT`` as the 256 256 full path to a directory where you'd like Django to store uploaded 257 257 files. (For performance, these files are not stored in the database.) django/branches/new-admin/docs/templates_python.txt
r876 r913 288 288 ".html" extension in a directory specified as a **template directory**. 289 289 290 (The ".html" extension is just a required convention. It doesn't mean templates 291 can only contain HTML. They can contain whatever textual content you want.) 290 If you don't like the requirement that templates have an ".html" extension, 291 change your ``TEMPLATE_FILE_EXTENSION`` setting. It's set to ``".html"`` by 292 default. 293 294 Also, the .html extension doesn't mean templates can contain only HTML. They 295 can contain whatever textual content you want. 292 296 293 297 The TEMPLATE_DIRS setting … … 355 359 356 360 get_template("news/story_detail") 361 362 Loader types 363 ~~~~~~~~~~~~ 364 365 By default, Django uses a filesystem-based template loader, but Django comes 366 with a few other template loaders. They're disabled by default, but you can 367 activate them by editing your ``TEMPLATE_LOADERS`` setting. 368 ``TEMPLATE_LOADERS`` should be a tuple of strings, where each string represents 369 a template loader. Here are the built-in template loaders: 370 371 ``django.core.template.loaders.filesystem.load_template_source`` 372 Loads templates from the filesystem, according to ``TEMPLATE_DIRS``. 373 374 ``django.core.template.loaders.app_directories.load_template_source`` 375 Loads templates from Django apps on the filesystem. For each app in 376 ``INSTALLED_APPS``, the loader looks for a ``templates`` subdirectory. If 377 the directory exists, Django looks for templates in there. 378 379 This means you can store templates with your individual apps. This also 380 makes it easy to distribute Django apps with default templates. 381 382 For example, for this setting:: 383 384 INSTALLED_APPS = ('myproject.polls', 'myproject.music') 385 386 ...then ``get_template("foo")`` will look for templates in these 387 directories, in this order: 388 389 * ``/path/to/myproject/polls/templates/foo.html`` 390 * ``/path/to/myproject/music/templates/music.html`` 391 392 Note that the loader performs an optimization when it is first imported: 393 It caches a list of which ``INSTALLED_APPS`` packages have a ``templates`` 394 subdirectory. 395 396 ``django.core.template.loaders.eggs.load_template_source`` 397 Just like ``app_directories`` above, but it loads templates from Python 398 eggs rather than from the filesystem. 399 400 Django uses the template loaders in order according to the ``TEMPLATE_LOADERS`` 401 setting. It uses each loader until a loader finds a match. 357 402 358 403 Extending the template system django/branches/new-admin/docs/templates.txt
r864 r913 224 224 if you want to add to the contents of a parent block instead of 225 225 completely overriding it. 226 227 Finally, note that you can't define multiple ``{% block %}`` tags with the same 228 name in the same template. This limitation exists because a block tag works in 229 "both" directions. That is, a block tag doesn't just provide a hole to fill -- 230 it also defines the content that fills the hole in the *parent*. If there were 231 two similarly-named ``{% block %}`` tags in a template, that template's parent 232 wouldn't know which one of the blocks' content to use. 226 233 227 234 Using the built-in reference … … 393 400 394 401 {% if athlete_list %} 395 Number of athletes: {{ athlete_list| count}}402 Number of athletes: {{ athlete_list|length }} 396 403 {% else %} 397 404 No athletes. … … 399 406 400 407 In the above, if ``athlete_list`` is not empty, the number of athletes will be 401 displayed by the ``{{ athlete_list| count}}`` variable.408 displayed by the ``{{ athlete_list|length }}`` variable. 402 409 403 410 As you can see, the ``if`` tag can take an option ``{% else %}`` clause that … … 426 433 {% if athlete_list %} 427 434 {% if coach_list %} 428 Number of athletes: {{ athlete_list| count}}.429 Number of coaches: {{ coach_list| count}}.435 Number of athletes: {{ athlete_list|length }}. 436 Number of coaches: {{ coach_list|length }}. 430 437 {% endif %} 431 438 {% endif %}
