Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Added a cavaet to the use of get_FOO_filename() and get_FOO_url(). This

constraint has always existed, but it's very hard to fix in the current code,
so better to work around it for now.

Refs #5619


git-svn-id: http://code.djangoproject.com/svn/django/trunk@7999 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit e942636fbef8c8a7f799ac798597b99f003a038d 1 parent 5141b67
Malcolm Tredinnick authored July 19, 2008

Showing 1 changed file with 12 additions and 0 deletions. Show diff stats Hide diff stats

  1. 12  docs/db-api.txt
12  docs/db-api.txt
@@ -2280,6 +2280,12 @@ For every ``FileField``, the object will have a ``get_FOO_filename()`` method,
2280 2280
 where ``FOO`` is the name of the field. This returns the full filesystem path
2281 2281
 to the file, according to your ``MEDIA_ROOT`` setting.
2282 2282
 
  2283
+.. note::
  2284
+    If you are using the ``upload_to`` parameter in your ``FileField``, it is
  2285
+    only valid to call this method **after** saving the model when the field
  2286
+    has been set. Prior to saving, the value returned will not contain the
  2287
+    upload directory in the path.
  2288
+
2283 2289
 Note that ``ImageField`` is technically a subclass of ``FileField``, so every
2284 2290
 model with an ``ImageField`` will also get this method.
2285 2291
 
@@ -2291,6 +2297,12 @@ where ``FOO`` is the name of the field. This returns the full URL to the file,
2291 2297
 according to your ``MEDIA_URL`` setting. If the value is blank, this method
2292 2298
 returns an empty string.
2293 2299
 
  2300
+.. note::
  2301
+    As with ``get_FOO_filename()``, if you are using the ``upload_to``
  2302
+    parameter on your ``FileField``, it is only valid to call this method
  2303
+    **after** saving the model, otherwise an incorrect result will be
  2304
+    returned.
  2305
+
2294 2306
 get_FOO_size()
2295 2307
 --------------
2296 2308
 

0 notes on commit e942636

Please sign in to comment.
Something went wrong with that request. Please try again.