Changeset 898
- Timestamp:
- 10/17/05 06:33:01 (3 years ago)
- Files:
-
- django/branches/i18n/django/conf/admin_templates/changelist_generic.html (deleted)
- django/branches/i18n/django/conf/global_settings.py (modified) (2 diffs)
- django/branches/i18n/django/conf/project_template/settings/main.py (modified) (1 diff)
- django/branches/i18n/django/core/template/loaders/app_directories.py (added)
- django/branches/i18n/django/core/template/loaders/eggs.py (modified) (2 diffs)
- django/branches/i18n/django/core/template/loaders/filesystem.py (modified) (1 diff)
- django/branches/i18n/docs/design_philosophies.txt (modified) (1 diff)
- django/branches/i18n/docs/model-api.txt (modified) (1 diff)
- django/branches/i18n/docs/settings.txt (added)
- django/branches/i18n/docs/templates_python.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/branches/i18n/django/conf/global_settings.py
r897 r898 80 80 # documentation. 81 81 TEMPLATE_LOADERS = ( 82 # 'django.core.template.loaders.app_directories.load_template_source', 82 83 'django.core.template.loaders.filesystem.load_template_source', 83 84 # 'django.core.template.loaders.eggs.load_template_source', … … 124 125 # settings modules (in the format 'foo.bar.baz') for which this admin 125 126 # is an admin. 126 ADMIN_FOR = []127 ADMIN_FOR = () 127 128 128 129 # Whether to check the flat-pages table as a last resort for all 404 errors. django/branches/i18n/django/conf/project_template/settings/main.py
r897 r898 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/i18n/django/core/template/loaders/eggs.py
r874 r898 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/i18n/django/core/template/loaders/filesystem.py
r874 r898 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/i18n/docs/design_philosophies.txt
r869 r898 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/i18n/docs/model-api.txt
r853 r898 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/i18n/docs/templates_python.txt
r869 r898 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
