Changeset 749
- Timestamp:
- 09/30/05 12:26:00 (3 years ago)
- Files:
-
- django/branches/new-admin/django/core/rss.py (modified) (4 diffs)
- django/branches/new-admin/docs/db-api.txt (modified) (1 diff)
- django/branches/new-admin/docs/model-api.txt (modified) (2 diffs)
- django/branches/new-admin/docs/tutorial01.txt (modified) (4 diffs)
- django/branches/new-admin/docs/tutorial03.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/branches/new-admin/django/core/rss.py
r3 r749 8 8 class FeedConfiguration: 9 9 def __init__(self, slug, title_cb, link_cb, description_cb, get_list_func_cb, get_list_kwargs, 10 param_func=None, param_kwargs_cb=None, get_list_kwargs_cb=None, 10 param_func=None, param_kwargs_cb=None, get_list_kwargs_cb=None, get_pubdate_cb=None, 11 11 enc_url=None, enc_length=None, enc_mime_type=None): 12 12 """ … … 29 29 get_list_kwargs_cb -- Function that takes the param and returns a 30 30 dictionary to use in addition to get_list_kwargs (if applicable). 31 32 get_pubdate_cb -- Function that takes the object and returns a datetime 33 to use as the publication date in the feed. 31 34 32 35 The three enc_* parameters are strings representing methods or … … 42 45 self.param_func, self.param_kwargs_cb = param_func, param_kwargs_cb 43 46 self.get_list_kwargs_cb = get_list_kwargs_cb 47 self.get_pubdate_cb = get_pubdate_cb 44 48 assert (None == enc_url == enc_length == enc_mime_type) or (enc_url is not None and enc_length is not None and enc_mime_type is not None) 45 49 self.enc_url = enc_url … … 96 100 unique_id=link, 97 101 enclosure=enc, 102 pubdate = self.get_pubdate_cb and self.get_pubdate_cb(obj) or None, 98 103 ) 99 104 return f django/branches/new-admin/docs/db-api.txt
r691 r749 525 525 ------------- 526 526 527 For every ``FileField``, the object will have a ``get_FOO_ filename()`` method,527 For every ``FileField``, the object will have a ``get_FOO_url()`` method, 528 528 where ``FOO`` is the name of the field. This returns the full URL to the file, 529 529 according to your ``MEDIA_URL`` setting. If the value is blank, this method django/branches/new-admin/docs/model-api.txt
r649 r749 249 249 250 250 The admin represents this as an ``<input type="file">`` (a file-upload widget). 251 251 252 Using a `FieldField` or an ``ImageField`` (see below) in a model takes a few 253 steps: 254 255 1. In your settings file, you'll need to define ``MEDIA_ROOT``as the 256 full path to a directory where you'd like Django to store uploaded 257 files. (For performance, these files are not stored in the database.) 258 Define ``MEDIA_URL`` as the base public URL of that directory. Make 259 sure that this directory is writable by the Web server's user 260 account. 261 262 2. Add the ``FileField`` or ``ImageField`` to your model, making sure 263 to define the ``upload_to`` option to tell Django to which 264 subdirectory of ``MEDIA_ROOT`` it should upload files. 265 266 3. All that will be stored in your database is a path to the file 267 (relative to ``MEDIA_ROOT``). You'll must likely want to use the 268 convenience ``get_<fieldname>_url`` function provided by Django. For 269 example, if your ``ImageField`` is called ``mug_shot``, you can get 270 the absolute URL to your image in a template with ``{{ 271 object.get_mug_shot_url }}``. 272 252 273 .. _`strftime formatting`: http://docs.python.org/lib/module-time.html#l2h-1941 253 274 … … 282 303 283 304 Requires the `Python Imaging Library`_. 284 305 285 306 .. _Python Imaging Library: http://www.pythonware.com/products/pil/ 286 307 django/branches/new-admin/docs/tutorial01.txt
r703 r749 386 386 # keyword arguments. 387 387 >>> polls.get_object(id__exact=1) 388 What's up 388 What's up? 389 389 >>> polls.get_object(question__startswith='What') 390 What's up 390 What's up? 391 391 >>> polls.get_object(pub_date__year=2005) 392 What's up 392 What's up? 393 393 >>> polls.get_object(id__exact=2) 394 394 Traceback (most recent call last): … … 396 396 PollDoesNotExist: Poll does not exist for {'id__exact': 2} 397 397 >>> polls.get_list(question__startswith='What') 398 [What's up ]398 [What's up?] 399 399 400 400 # Lookup by a primary key is the most common case, so Django provides a … … 402 402 # The following is identical to polls.get_object(id__exact=1). 403 403 >>> polls.get_object(pk=1) 404 What's up 404 What's up? 405 405 406 406 # Make sure our custom method worked. … … 420 420 # Choice objects have API access to their related Poll objects. 421 421 >>> c.get_poll() 422 What's up 422 What's up? 423 423 424 424 # And vice versa: Poll objects get access to Choice objects. django/branches/new-admin/docs/tutorial03.txt
r679 r749 92 92 93 93 The ``poll_id=23`` part comes from ``(?P<poll_id>\d+)``. Using 94 ``(? <name>pattern)`` "captures" the text matched by ``pattern`` and sends it as95 a keyword argument to the view function.94 ``(?P<name>pattern)`` "captures" the text matched by ``pattern`` and sends it 95 as a keyword argument to the view function. 96 96 97 97 Because the URL patterns are regular expressions, there really is no limit on
