Ticket #8189: model-api.diff
File model-api.diff, 1.5 KB (added by , 16 years ago) |
---|
-
Users/flavio/working_copies/django/docs/model-api.txt
296 296 297 297 3. All that will be stored in your database is a path to the file 298 298 (relative to ``MEDIA_ROOT``). You'll most likely want to use the 299 convenience ``get_<fieldname>_url`` functionprovided by Django. For299 ``<fieldname>.url`` attribute provided by Django. For 300 300 example, if your ``ImageField`` is called ``mug_shot``, you can get 301 301 the absolute URL to your image in a template with ``{{ 302 object. get_mug_shot_url }}``.302 object.mug_shot.url }}``. 303 303 304 304 For example, say your ``MEDIA_ROOT`` is set to ``'/home/media'``, and 305 305 ``upload_to`` is set to ``'photos/%Y/%m/%d'``. The ``'%Y/%m/%d'`` part of … … 310 310 311 311 If you want to retrieve the upload file's on-disk filename, or a URL that 312 312 refers to that file, or the file's size, you can use the 313 `` get_FOO_filename()``, ``get_FOO_url()`` and ``get_FOO_size()`` methods.313 ``FOO.path``, ``FOO.url`` and ``FOO.size`` attributes. 314 314 They are all documented here__. 315 315 316 __ ../ db-api/#get-foo-filename316 __ ../files/#file-attributes-and-methods 317 317 318 318 Note that whenever you deal with uploaded files, you should pay close attention 319 319 to where you're uploading them and what type of files they are, to avoid