Changeset 136
- Timestamp:
- 07/16/05 23:20:57 (3 years ago)
- Files:
-
- django/trunk/docs/model-api.txt (modified) (14 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/trunk/docs/model-api.txt
r67 r136 3 3 =============== 4 4 5 Django's models are the bread and butter of the framework. There's a huge 6 array of options available to you when defining your data models ; this7 document explains all ofthem.5 Django's models are the bread and butter of the framework. There's a huge 6 array of options available to you when defining your data models. This 7 document explains them. 8 8 9 9 Options for models 10 10 ================== 11 11 12 A list of all possible options for a model object follows. Although there's a13 wide array of possibleoptions, only ``fields`` is required.12 A list of all possible options for a model object follows. Although there's a 13 wide array of options, only ``fields`` is required. 14 14 15 15 ``admin`` 16 16 A ``meta.Admin`` object; see `Admin options`_. If this field isn't given, 17 17 the object will not have an admin interface. 18 18 19 19 ``db_table`` 20 20 The name of the database table to use for the module:: 21 21 22 22 db_table = "pizza_orders" 23 24 If not given, thiswill use ``app_label + '_' + module_name``.25 23 24 If this isn't given, Django will use ``app_label + '_' + module_name``. 25 26 26 ``exceptions`` 27 27 Names of extra exception subclasses to include in the generated module. 28 28 These exceptions are available from instance methods and from module-level 29 29 methods:: 30 30 31 31 exceptions = ("DisgustingToppingsException", "BurntCrust") 32 32 33 33 ``fields`` 34 A list of field objects ; see `Field objects`_.For example::35 34 A list of field objects. See `Field objects`_. For example:: 35 36 36 fields = ( 37 37 meta.CharField('customer_name', 'customer name', maxlength=15), … … 40 40 ... 41 41 ) 42 42 43 43 ``get_latest_by`` 44 The name of a date or datetime field; if given, the module will have a45 ``get_latest()`` function which fetches the "latest" object in terms of46 t hat field::47 44 The name of a ``DateField`` or ``DateTimeField``; if given, the module will 45 have a ``get_latest()`` function that fetches the "latest" object according 46 to that field:: 47 48 48 get_latest_by = "order_date" 49 49 50 50 ``module_constants`` 51 A dict of name/values to use as extra module-level constants::52 51 A dictionary of names/values to use as extra module-level constants:: 52 53 53 module_constants = { 54 54 'MEAT_TYPE_PEPPERONI' : 1, 55 55 'MEAT_TYPE_SAUSAGE' : 2, 56 56 } 57 57 58 58 ``module_name`` 59 59 The name of the module:: 60 60 61 61 module_name = "pizza_orders" 62 63 If not given this will use a lowercased version of the class name. 64 62 63 If this isn't given, Django will use a lowercased version of the class 64 name, plus "s". 65 65 66 ``order_with_respect_to`` 66 67 Marks this object as "orderable" with respect to the given field. This is … … 68 69 respect to a parent object. For example, if a ``PizzaToppping`` relates to 69 70 a ``Pizza`` object, you might use:: 70 71 71 72 order_with_respect_to = 'pizza_id' 72 73 73 74 to allow the toppings to be ordered with respect to the associated pizza. 74 75 75 76 ``ordering`` 76 The default ordering for th o object::77 77 The default ordering for the object, for use by ``get_list`` and the admin:: 78 78 79 ordering = (('order_date', 'DESC'),) 79 80 This is a tuple of 2-tuples ; each 2-tuple is ``(field_name, ordering_type)``81 where ordering_type is either ``"ASC"`` or ``"DESC"``. You mayalso use the82 magic ``(None, "RANDOM")`` ordering tuplefor random ordering.83 80 81 This is a tuple of 2-tuples. Each 2-tuple is ``(field_name, ordering_type)`` 82 where ordering_type is either ``"ASC"`` or ``"DESC"``. You can also use the 83 ``(None, "RANDOM")`` for random ordering. 84 84 85 ``permissions`` 85 86 Extra permissions to enter into the permissions table when creating this 86 object. A add, delete, and change permission is automatically created for87 each object ; this option specifies extra permissions::88 89 permissions = ((" may_delivier_pizzas", "Can deliver pizzas"),)90 91 This is a list of 2-tuples of 87 object. A add, delete, and change permission is automatically created for 88 each object. This option specifies extra permissions:: 89 90 permissions = (("can_delivier_pizzas", "Can deliver pizzas"),) 91 92 This is a list of 2-tuples of 92 93 ``(permission_code, human_readable_permission_name)``. 93 94 94 95 ``unique_together`` 95 96 Sets of field names that, taken together, must be unique:: 96 97 97 98 unique_together = (("driver_id", "restaurant_id"),) 98 99 99 100 This is a list of lists of fields that must be unique when considered 100 together. 101 101 together. It's used in the Django admin. 102 102 103 ``verbose_name`` 103 104 A human-readable name for the object, singular:: 104 105 105 106 verbose_name = "pizza" 106 107 If not given, thiswill use a munged version of the class name:107 108 If this isn't given, Django will use a munged version of the class name: 108 109 ``CamelCase`` becomes ``camel case``. 109 110 110 111 ``verbose_name_plural`` 111 112 The plural name for the object:: 112 113 113 114 verbose_name_plural = "stories" 114 115 If not given, ``verbose_name + "s"`` will automatically be used.116 115 116 If this isn't given, Django will use ``verbose_name + "s"``. 117 117 118 Field objects 118 119 ============= 119 120 120 121 The list of fields is the most important part of a data model. Each item in 121 the ``fields`` list is an instance of a ``meta.Field`` subclass ,and maps to122 the ``fields`` list is an instance of a ``meta.Field`` subclass and maps to 122 123 a database field. 123 124 … … 131 132 --------------------- 132 133 133 Each type of field takes a different set of options, but there are some134 options that are common to all field types.These options are:134 Each type of field takes a different set of options, but some options are 135 common to all field types. These options are: 135 136 136 137 ====================== =================================================== 137 138 Option Description 138 139 ====================== =================================================== 139 ``blank`` If ``True``, the field is allowed to be blank. 140 ``blank`` If ``True``, the field is allowed to be blank. 140 141 Note that this is different from ``null`` in that 141 142 string fields will store the empty string instead of 142 ``NULL`` internally ; this means that to create a143 ``NULL`` internally. This means that to create a 143 144 field that stores nulls you must pass ``blank=True`` 144 and ``null=True`` . 145 146 ``choices`` A list of 2-tuples to use as choices for this 147 field.If this is given, instead of the standard 148 field a option menu will be used, limiting choices 149 to the choices given. A choices list looks like:: 150 145 and ``null=True``. 146 147 ``choices`` A list of 2-tuples to use as choices for this 148 field. If this is given, Django's admin will use a 149 select box instead of the standard text field and 150 will limit choices to the choices given. A choices 151 list looks like:: 152 151 153 YEAR_IN_SCHOOL_CHOICES = ( 152 154 ('FR', 'Freshman'), … … 156 158 ('GR', 'Graduate'), 157 159 ) 158 160 159 161 The first element in each tuple is the actual value 160 to be stored ; the second element is the human161 readable name for the option.162 162 to be stored. The second element is the 163 human-readable name for the option. 164 163 165 ``core`` For objects that are edited inline to a related 164 166 object. If all "core" fields in an inline-edited 165 167 object are cleared, the object will be considered to 166 168 be deleted. 167 169 168 170 It is an error to have an inline-editable 169 171 relation without at least one core field. 170 172 171 173 ``db_index`` If ``True``, the SQL generator will create a database 172 174 index on this field. 173 175 174 176 ``default`` The default value for the field. 175 176 ``editable`` ``True`` by default, if set to ``False`` the field 177 will not be editable in the admin. 178 179 ``help_text`` Extra "help" text to be displayed with the field. 180 181 ``null`` If ``True`` empty values in the field will be 182 stored as ``NULL`` in the database. 183 184 ``primary_key`` If ``True`` this field is the primary key for the 185 table. You only need to use this if you don't want 177 178 ``editable`` ``True`` by default. If this is set to ``False``, 179 the field will not be editable in the admin. 180 181 ``help_text`` Extra "help" text to be displayed under the field 182 on the object's admin form. 183 184 ``null`` If ``True``, empty values in the field will be 185 stored as ``NULL`` in the database. 186 187 ``primary_key`` If ``True``, this field is the primary key for the 188 table. You only need to use this if you don't want 186 189 the standard "id" field created and used as the 187 190 primary key. 188 191 189 192 Implies ``blank=False``, ``null=False``, and 190 ``unique=True``. Only one primary key is allowed 191 on each object. 192 193 ``radio_admin`` If ``choices`` is given, or if the field is a 194 ManyToOne relation, use a radio button interface 195 for the choices instead of the standard options 196 menu interface. 197 198 ``unique`` If ``True`` this field must be unique throughout 199 the table. 200 201 ``unique_for_date`` Set this to the name of a ``DateField`` or 193 ``unique=True``. Only one primary key is allowed 194 on an object. 195 196 ``radio_admin`` If ``choices`` is given, or if the field is a 197 ManyToOne relation, use a radio-button interface 198 for the choices instead of the standard select-box 199 interface. 200 201 ``unique`` If ``True``, this field must be unique throughout 202 the table. This is enforced at the database level 203 and at the Django admin-form level. 204 205 ``unique_for_date`` Set this to the name of a ``DateField`` or 202 206 ``DateTimeField`` to require that this field 203 be unique for the value of the date field. That204 is, if you have a field, ``title`` that has207 be unique for the value of the date field. For 208 example, if you have a field ``title`` that has 205 209 ``unique_for_date="pub_date"``, then it is an 206 210 error to have two rows with the same ``title`` 207 211 and the same ``pub_date``. 208 212 209 213 ``unique_for_month`` Like ``unique_for_date``, but requires the field 210 214 to be unique with respect to the month. 211 212 ``unique_for_year`` Like ``unique_for_date`` and ``unique_for_month`` 213 but, well, you get the idea. 214 215 216 ``unique_for_year`` Like ``unique_for_date`` and ``unique_for_month``. 217 215 218 ``validator_list`` A list of extra validators to apply to the field. 216 See the `Form fields guide`_ for information about217 validators.218 219 ====================== =================================================== 219 220 .. _`Form fields guide`: http://www.djangoproject.com/FIXME/221 220 222 221 Field Types 223 222 ----------- 224 223 225 224 ``AutoField`` 226 An ``IntegerField`` that automatically increments. You usually won't need to227 use this directly; a primary key field will automatically be added to your 228 model if you don't specify otherwise. That automaticallyadded field is::229 225 An ``IntegerField`` that automatically increments. You usually won't need to 226 use this directly; a primary key field will automatically be added to your 227 model if you don't specify otherwise. That automatically-added field is:: 228 230 229 meta.AutoField('id', 'ID', primary_key=True) 231 230 232 231 ``BooleanField`` 233 232 A true/false field. 234 233 235 234 ``CharField`` 236 A text field. These are displayed in the admin as single-line text inputs, so 237 for large amounts of text use a ``TextField``. 238 239 ``CharField``s have an extra required argument: ``maxlength``; the maximum 240 length (in characters) of the field. 241 235 A text field. These are displayed in the admin as single-line text inputs, so 236 for large amounts of text, use a ``TextField``. 237 238 ``CharField``s have an extra required argument: ``maxlength``, the maximum 239 length (in characters) of the field. The maxlength is enforced at the database 240 level and in Django's admin validation. 241 242 242 ``CommaSeparatedIntegerField`` 243 243 A field of integers separated by commas. 244 244 245 245 ``DateField`` 246 A , um, date field.Has a few extra optional options:247 246 A date field. Has a few extra optional options: 247 248 248 ====================== =================================================== 249 249 Option Description 250 250 ====================== =================================================== 251 251 ``auto_now`` Automatically set the field to now every time the 252 object is saved. Useful for "last-modified"252 object is saved. Useful for "last-modified" 253 253 timestamps. 254 254 255 255 ``auto_now_add`` Automatically set the field to now when the object 256 is first created. Useful for creation timestamps. 256 is first created. Useful for creation of 257 timestamps. 257 258 ====================== =================================================== 258 259 259 260 ``DateTimeField`` 260 261 A date and time field. Takes the same extra options as ``DateField``. 261 262 262 263 263 ``EmailField`` 264 A ``CharField`` that checks that the value is a valid email address. Because 265 validating email addresses can be tricky, this is a pretty loose test. 266 264 A ``CharField`` that checks that the value is a valid e-mail address. 265 Because validating e-mail addresses can be tricky, this is a pretty loose 266 test. 267 267 268 ``FileField`` 268 A file-upload field. Takes on additional option, ``upload_to``which is269 a path to upload the file to. This path may contain `strftime formatting`_270 which will be replaced by the date/time of the file upload (so that uploaded271 files don't fill up the given directory).272 269 A file-upload field. Takes an additional option, ``upload_to``, which is 270 a local filesystem path to upload the file to. This path may contain 271 `strftime formatting`_, which will be replaced by the date/time of the file 272 upload (so that uploaded files don't fill up the given directory). 273 273 274 .. _`strftime formatting`: http://docs.python.org/lib/module-time.html#l2h-1941 274 275 275 276 ``FloatField`` 276 A floating-point number. Has two additional required options:277 277 A floating-point number. Has two additional required options: 278 278 279 ====================== =================================================== 279 280 Option Description 280 281 ====================== =================================================== 281 282 ``max_digits`` The maximum number of digits allowed in the number. 282 283 283 284 ``decimal_places`` The number of decimal places to store with the 284 285 number 285 286 ====================== =================================================== 286 287 287 288 For example, to store numbers up to 999 with a resolution of 2 decimal places, 288 289 you'd use:: 289 290 290 291 meta.FloatField(..., max_digits=5, decimal_places=2) 291 292 292 293 And to store numbers up to one million with a resolution of 10 decimal places:: 293 294 294 295 meta.FloatField(..., max_digits=19, decimal_places=10) 295 296 296 297 ``ForeignKey`` 297 A many-to-one relationship to the primary key in another object. So, to give a298 ``Topping`` object a many-to-one relationship to ``Pizza`` (i.e. there are 298 A many-to-one relationship to the primary key in another object. So, to give a 299 ``Topping`` object a many-to-one relationship to ``Pizza`` (i.e. there are 299 300 many toppings on a pizza):: 300 301 301 302 meta.ForeignKey(Pizza) 302 303 303 304 ``ForeignKey`` fields take a large number of extra options for defining how 304 305 the relationship should work: 305 306 306 307 ======================= ============================================================ 307 308 Option Description 308 309 ======================= ============================================================ 309 ``edit_inline`` If ``True``, this related object is edited 310 "inline" on the related object's page. This means311 that the object will not have its own admin 312 interface. 313 314 ``edit_inline_type`` This is either ``meta.TABULAR`` or 315 ``meta.STACKED`` and controls w eather the inline310 ``edit_inline`` If ``True``, this related object is edited 311 "inline" on the related object's page. This means 312 that the object will not have its own admin 313 interface. 314 315 ``edit_inline_type`` This is either ``meta.TABULAR`` or 316 ``meta.STACKED`` and controls whether the inline 316 317 editable objects are displayed as a table or as 317 a "stack" of fieldsets. Defaults to 318 a "stack" of fieldsets. Defaults to 318 319 ``meta.STACKED``. 319 320 320 321 ``limit_choices_to`` A dictionary of lookup arguments and values (see 321 the `Database API reference`_) t o limit choices322 of this object to. Use this along with323 ``meta.LazyDate`` to limit choices of objects324 by date , for example::325 322 the `Database API reference`_) that limit the 323 available admin choices for this object. Use this 324 with ``meta.LazyDate`` to limit choices of objects 325 by date. For example:: 326 326 327 limit_choices_to = {'pub_date__lte' : meta.LazyDate()} 327 328 328 329 only allows the choice of related objects with a 329 330 ``pub_date`` before the current date/time to be 330 331 chosen. 331 332 332 333 Not compatible with ``edit_inline``. 333 334 334 335 ``max_num_in_admin`` For inline-edited objects, this is the maximum 335 336 number of related objects to display in the admin. 336 Thus, if a pizza could only have up to 10 337 Thus, if a pizza could only have up to 10 337 338 toppings, ``max_num_in_admin=10`` would ensure 338 339 that a user never enters more than 10 toppings. 339 340 340 341 Note that this doesn't ensure more than 10 related 341 toppings ever get created. 342 342 toppings ever get created. It just controls the 343 interface. 344 343 345 ``min_num_in_admin`` The minimum number of related objects displayed in 344 the admin. Normally, at the creation stage346 the admin. Normally, at the creation stage, 345 347 ``num_in_admin`` inline objects are shown, and at 346 the edit stage ``num_extra_on_change`` objects are347 shown in addition to all pre-existing related348 objects. However, no fewer than348 the edit stage ``num_extra_on_change`` blank 349 objects are shown in addition to all pre-existing 350 related objects. However, no fewer than 349 351 ``min_num_in_admin`` related objects will ever be 350 352 displayed. 351 352 ``num_extra_on_change`` The number of extra blank related object fields to353 354 ``num_extra_on_change`` The number of extra blank related-object fields to 353 355 show at the change stage. 354 356 355 357 ``num_in_admin`` The default number of inline objects to display 356 358 on the object page at the add stage. 357 359 358 360 ``raw_id_admin`` Only display a field for the integer to be entered 359 instead of a drop-down menu. This is useful when361 instead of a drop-down menu. This is useful when 360 362 related to an object type that will have too many 361 rows to make a menupractical.362 363 rows to make a select box practical. 364 363 365 Not used with ``edit_inline``. 364 365 ``rel_name`` The name of the relation. In the above example,366 this would default to 'pizza' (so that the 366 367 ``rel_name`` The name of the relation. In the above example, 368 this would default to 'pizza' (so that the 367 369 ``Toppings`` object would have a ``get_pizza()`` 368 function ; if you set ``rel_name`` to "pie", then370 function. If you set ``rel_name`` to "pie", then 369 371 the function would be called ``get_pie()`` and the 370 372 field name would be ``pie_id``. 371 373 372 374 ``related_name`` The name to use for the relation from the related 373 375 object back to this one. For example, when if 374 376 ``Topping`` has this field:: 375 377 376 378 meta.ForeignKey(Pizza) 377 379 378 380 the ``related_name`` will be "topping" (taken from 379 381 the class name which will in turn give ``Pizza`` 380 methods like ``get_topping_list()`` and 381 ``get_topping_count()``. 382 382 methods like ``get_topping_list()`` and 383 ``get_topping_count()``. 384 383 385 If you instead were to use:: 384 386 385 387 meta.ForeignKey(Pizza, related_name="munchie") 386 388 387 389 then the methods would be called 388 390 ``get_munchie_list()``, ``get_munchie_count()``, 389 391 etc. 390 392 391 393 This is only really useful when you have a single 392 394 object that relates to the same object more than 393 395 once. For example, if a ``Story`` object has both 394 ``primary_category`` and ``secondary_category`` 396 ``primary_category`` and ``secondary_category`` 395 397 fields, to make sure that the category objects 396 398 have the correct methods, you'd use fields like:: 397 399 398 400 ... 399 401 meta.ForeignKey(Category, name="primary_category_id", 400 402 rel_name="primary_category", 401 403 related_name="primary_story"), 402 404 403 405 meta.ForeignKey(Category, name="secondary_category_id", 404 406 rel_name="secondary_category", 405 407 related_name="secondary_story"), 406 408 ... 407 408 which would give the category objects methods 409 named ``get_primary_story_list()`` and 409 410 which would give the category objects methods 411 named ``get_primary_story_list()`` and 410 412 ``get_secondary_story_list()``. 411 413 412 414 ``to_field`` The field on the related object that the relation 413 is to. This is almost always ``id``, but if the414 PK on the other object is named something415 is to. This is almost always ``id``, but if the 416 primary key on the other object is named something 415 417 different, this is how to indicate that. 416 418 ======================= ============================================================ 417 419 418 .. _`Database API reference`: http://www.djangoproject.com/documentation/db_api/ 419 420 .. _`Database API reference`: http://www.djangoproject.com/documentation/db_api/ 421 420 422 ``ImageField`` 421 Like a ``FieldField``, but validates that the uploaded object is a valid 422 image. Has two extra optional arguments, ``height_field`` and ``width_field``423 Like a ``FieldField``, but validates that the uploaded object is a valid 424 image. Has two extra optional arguments, ``height_field`` and ``width_field`` 423 425 which, if set, will be auto-populated with the height and width of the image. 424 426 427 Requires the `Python Imaging Library`_. 428 429 .. _Python Imaging Library: http://www.pythonware.com/products/pil/ 430 425 431 ``IntegerField`` 426 An integer , surprisingly.427 432 An integer. 433 428 434 ``IPAddressField`` 429 435 An IP address, in string format (i.e. "24.124.1.30"). 430 436 431 437 ``ManyToManyField`` 432 438 A many-to-many relation to another object. For example (taken from the 433 439 ``core.flatfiles`` object:: 434 440 435 441 class FlatFile(meta.Model): 436 442 fields = ( … … 438 444 meta.ManyToManyField(Site), 439 445 ) 440 446 441 447 Many-to-many relations are a bit different from other fields. First, they 442 aren't actually a field per se since they use a intermediary join table.443 Second, they don't take any of the same options as the rest of the fields ,444 the only options taken are:445 448 aren't actually a field per se, because they use a intermediary join table. 449 Second, they don't take any of the same options as the rest of the fields. 450 The only options taken are: 451 446 452 ======================= ============================================================ 447 453 Option Description 448 454 ======================= ============================================================ 449 ``related_name`` See the description of ``related_name`` in 455 ``related_name`` See the description of ``related_name`` in 450 456 ``ManyToOneField``, above. 451 452 ``filter_interface`` Use a nifty unobtrusive Javascript "filter" interface 453 instead of the usability-challenged ``<select multiple>``. 454 The value should be ``meta.HORIZONTAL`` or ``meta.VERTICAL`` 455 (i.e. should the interface be stacked horizontally or 457 458 ``filter_interface`` Use a nifty unobtrusive Javascript "filter" interface 459 instead of the usability-challenged ``<select multiple>`` 460 in the admin form for this object. The value should be 461 ``meta.HORIZONTAL`` or ``meta.VERTICAL`` (i.e. 462 should the interface be stacked horizontally or 456 463 vertically). 457 464 458 465 ``limit_choices_to`` See the description under ``ManyToOneField``, above. 459 466 ======================= ============================================================ … … 461 468 ``NullBooleanField`` 462 469 Like a ``BooleanField``, but allows ``NULL`` as one of the options. Use this 463 instead of a ``BooleanField`` with ``null=True`` .464 470 instead of a ``BooleanField`` with ``null=True``. 471 465 472 ``OneToOneField`` 466 473 Signifies a one-to-one relationship. This is most useful on the primary key 467 of an object when that object "extends" another object in some way. 468 474 of an object when that object "extends" another object in some way. 475 469 476 For example, if you are building a database of "places", you would build pretty 470 477 standard stuff like address, phone number, etc. in the database. If you then … … 475 482 the primary key ``id`` field (since one-to-one relations share the same 476 483 primary key), and has a few in the admin interface: 477 484 478 485 * No selection interface is displayed on ``Restaurant`` pages; there will 479 486 be one (and only one) ``Restaurant`` for each place. 480 487 481 488 * On the ``Restaurant`` change list, every single ``Place`` -- weather it 482 has an associated ``Restaurant`` or not -- will be displayed. Adding489 has an associated ``Restaurant`` or not -- will be displayed. Adding 483 490 a ``Restaurant`` to a ``Place`` just means filling out the required 484 491 ``Restaurant`` fields. … … 486 493 ``PhoneNumberField`` 487 494 Validates that the value is a valid phone number. 488 495 489 496 ``PositiveIntegerField`` 490 497 Like an ``IntegerField``, but must be positive. 491 498 492 499 ``PositiveSmallIntegerField`` 493 Like a ``PositiveIntegerField``, but only allows values below 32767. 494 500 Like a ``PositiveIntegerField``, but only allows values under a certain 501 (database-dependent) point. 502 495 503 ``SlugField`` 496 A "slug " suitable for parts of a URL; only allows alpha-numeric characters and497 underscores.498 504 A "slug," suitable for parts of a URL. Only allows alphanumeric characters 505 and underscores. 506 499 507 Implies ``maxlength=50`` and ``db_index=True``. 500 501 Accepts an extra option, ``prepopulate_from`` which is a list of fields from 502 which to auto-populate the slug. 503 508 509 Accepts an extra option, ``prepopulate_from``, which is a list of fields 510 from which to auto-populate the slug, via JavaScript, in the object's admin 511 form. 512 504 513 ``SmallIntegerField`` 505 Like an ``IntegerField``, but must be between -32768 and 32767. 506 514 Like an ``IntegerField``, but only allows values under a certain 515 (database-dependent) point. 516 507 517 ``TextField`` 508 518 A large text field (``<textarea>`` in HTML). 509 519 510 520 ``TimeField`` 511 A time. Accepts the same auto-population options as ``DateField`` and521 A time. Accepts the same auto-population options as ``DateField`` and 512 522 ``DateTimeField``. 513 523 514 524 ``URLField`` 515 A field for a URL. If the ``verify_exists`` option is ``True`` , the URL given516 will be checked for existence (i.e. actually loads and doesn't give a 404517 response).518 525 A field for a URL. If the ``verify_exists`` option is ``True`` (default), 526 the URL given will be checked for existence (i.e., the URL actually loads 527 and doesn't give a 404 response). 528 519 529 ``USStateField`` 520 A US state.521 530 A two-letter U.S. state abbreviation. 531 522 532 ``XMLField`` 523 A field containing XML. Takes one required argument, ``schema_path`` which 524 is the path to a RelaxNG_ scheme against which to validate the field. 525 533 A field containing XML. Takes one required argument, ``schema_path``, which 534 is the filesystem path to a RelaxNG_ schema against which to validate the 535 field. 536 526 537 .. _RelaxNG: http://www.relaxng.org/ 527 538 … … 530 541 531 542 The ``admin`` field in the model tells Django how to construct the admin 532 interface for the object. The field is an instance of the ``meta.Admin`` 543 interface for the object. The field is an instance of the ``meta.Admin`` 533 544 object, which has the following options (of which only ``fields`` is required): 534 545 535 ``date_hierarchy`` 546 ``date_hierarchy`` 536 547 To allow filtering of objects in the admin by date, set ``date_hierarchy`` 537 548 to the name of the field to filter by:: 538 549 539 550 date_hierarchy = 'order_date' 540 551 541 552 ``fields`` 542 553 A list of fieldsets to display on the admin page. Each fieldset is a 2-tuple: 543 554 ``(name, field_options)``. The ``name`` is a string to name the field set, 544 and ``field_options`` is a dictionary of information about the fields to be 545 displayed in that fieldset. This dictionary has the following keys:546 555 and ``field_options`` is a dictionary of information about the fields to be 556 displayed in that fieldset. This dictionary has the following keys: 557 547 558
