summaryrefslogtreecommitdiff
path: root/docs/faq/usage.txt
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/faq/usage.txt
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/faq/usage.txt')
-rw-r--r--docs/faq/usage.txt33
1 files changed, 18 insertions, 15 deletions
diff --git a/docs/faq/usage.txt b/docs/faq/usage.txt
index 67565a5807..6e1f0dac3d 100644
--- a/docs/faq/usage.txt
+++ b/docs/faq/usage.txt
@@ -45,21 +45,24 @@ Django database layer.
How do I use image and file fields?
-----------------------------------
-Using a ``FileField`` or an ``ImageField`` in a model takes a few steps:
+Using a :class:`~django.db.models.FileField` or an
+:class:`~django.db.models.ImageField` in a model takes a few steps:
- #. In your settings file, define ``MEDIA_ROOT`` as the full path to
- a directory where you'd like Django to store uploaded files. (For
- performance, these files are not stored in the database.) Define
- ``MEDIA_URL`` as the base public URL of that directory. Make sure that
- this directory is writable by the Web server's user account.
+ #. In your settings file, you'll need to define :setting:`MEDIA_ROOT` as the
+ full path to a directory where you'd like Django to store uploaded files.
+ (For performance, these files are not stored in the database.) Define
+ :setting:`MEDIA_URL` as the base public URL of that directory. Make sure
+ that this directory is writable by the Web server's user account.
- #. Add the ``FileField`` or ``ImageField`` to your model, making sure
- to define the ``upload_to`` option to tell Django to which subdirectory
- of ``MEDIA_ROOT`` it should upload files.
+ #. Add the :class:`~django.db.models.FileField` or
+ :class:`~django.db.models.ImageField` to your model, making sure to
+ define the :attr:`~django.db.models.FileField.upload_to` option to tell
+ Django to which subdirectory of :setting:`MEDIA_ROOT` it should upload
+ files.
- #. All that will be stored in your database is a path to the file
- (relative to ``MEDIA_ROOT``). You'll most likely want to use the
- convenience ``get_<fieldname>_url`` function provided by Django. For
- example, if your ``ImageField`` is called ``mug_shot``, you can get the
- absolute URL to your image in a template with
- ``{{ object.get_mug_shot_url }}``.
+ #. 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 :attr:`~django.core.files.File.url` attribute provided by
+ Django. For example, if your :class:`~django.db.models.ImageField` is
+ called ``mug_shot``, you can get the absolute URL to your image in a
+ template with ``{{ object.mug_shot.url }}``.