summaryrefslogtreecommitdiff
path: root/docs/ref/models
diff options
context:
space:
mode:
authorJacob Kaplan-Moss <jacob@jacobian.org>2008-09-02 17:33:51 +0000
committerJacob Kaplan-Moss <jacob@jacobian.org>2008-09-02 17:33:51 +0000
commitbc768e2b471b707bfbb234c21066a4b0cbbe9258 (patch)
tree62734c7accd958a50f5a5549d883cc0c05912621 /docs/ref/models
parentc1de41f4d29d15616075ffd474e3aba7adcfc64f (diff)
A bunch of cleanups to file documentation. Along the way some references to the old file methods were removed - thanks, varikin.
Fixes #8642. git-svn-id: http://code.djangoproject.com/svn/django/trunk@8862 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'docs/ref/models')
-rw-r--r--docs/ref/models/fields.txt33
1 files changed, 17 insertions, 16 deletions
diff --git a/docs/ref/models/fields.txt b/docs/ref/models/fields.txt
index 370c0284df..8412f02d73 100644
--- a/docs/ref/models/fields.txt
+++ b/docs/ref/models/fields.txt
@@ -415,20 +415,20 @@ A file-upload field. Has one **required** argument:
.. attribute:: FileField.upload_to
A local filesystem path that will be appended to your :setting:`MEDIA_ROOT`
- setting to determine the output of the ``get_<fieldname>_url()`` helper
- function.
+ setting to determine the value of the :attr:`~django.core.files.File.url`
+ attribute.
This path may contain `strftime formatting`_, which will be replaced by the
date/time of the file upload (so that uploaded files don't fill up the given
directory).
- .. versionadded:: 1.0
+ .. versionchanged:: 1.0
This may also be a callable, such as a function, which will be called to
- obtain the upload path, including the filename. This callable must be
- able to accept two arguments, and return a Unix-style path (with forward
- slashes) to be passed along to the storage system. The two arguments that will
- be passed are:
+ obtain the upload path, including the filename. This callable must be able
+ to accept two arguments, and return a Unix-style path (with forward slashes)
+ to be passed along to the storage system. The two arguments that will be
+ passed are:
====================== ===============================================
Argument Description
@@ -470,15 +470,15 @@ takes a few steps:
that this directory is writable by the Web server's user account.
2. Add the :class:`FileField` or :class:`ImageField` to your model, making
- sure to define the :attr:`~FileField.upload_to` option to tell Django to
- which subdirectory of :setting:`MEDIA_ROOT` it should upload files.
+ sure to define the :attr:`~FileField.upload_to` option to tell Django
+ to which subdirectory of :setting:`MEDIA_ROOT` it should upload files.
3. All that will be stored in your database is a path to the file
(relative to :setting:`MEDIA_ROOT`). You'll most likely want to use the
- convenience ``get_<fieldname>_url`` function provided by Django. For
- example, if your :class:`ImageField` is called ``mug_shot``, you can get
- the absolute URL to your image in a template with ``{{
- object.get_mug_shot_url }}``.
+ convenience :attr:`~django.core.files.File.url` function provided by
+ Django. For example, if your :class:`ImageField` is called ``mug_shot``,
+ you can get the absolute URL to your image in a template with
+ ``{{ object.mug_shot.url }}``.
For example, say your :setting:`MEDIA_ROOT` is set to ``'/home/media'``, and
:attr:`~FileField.upload_to` is set to ``'photos/%Y/%m/%d'``. The ``'%Y/%m/%d'``
@@ -488,8 +488,9 @@ day. If you upload a file on Jan. 15, 2007, it will be saved in the directory
``/home/media/photos/2007/01/15``.
If you want to retrieve the upload file's on-disk filename, or a URL that refers
-to that file, or the file's size, you can use the ``File.name``, ``File.url``
-and ``File.size`` attributes; see :ref:`topics-files`.
+to that file, or the file's size, you can use the
+:attr:`~django.core.files.File.name`, :attr:`~django.core.files.File.url`
+and :attr:`~django.core.files.File.size` attributes; see :ref:`topics-files`.
Note that whenever you deal with uploaded files, you should pay close attention
to where you're uploading them and what type of files they are, to avoid
@@ -581,7 +582,7 @@ image. Has two extra optional arguments:
Name of a model field which will be auto-populated with the height of the
image each time the model instance is saved.
-.. attribute:: ImageField.width_field`
+.. attribute:: ImageField.width_field
Name of a model field which will be auto-populated with the width of the
image each time the model instance is saved.