From a19ed8aea395e8e07164ff7d85bd7dff2f24edca Mon Sep 17 00:00:00 2001 From: Brian Rosner Date: Fri, 18 Jul 2008 23:54:34 +0000 Subject: Merged the newforms-admin branch into trunk. This is a backward incompatible change. The admin contrib app has been refactored. The newforms module has several improvements including FormSets and Media definitions. git-svn-id: http://code.djangoproject.com/svn/django/trunk@7967 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- docs/model-api.txt | 478 ----------------------------------------------------- 1 file changed, 478 deletions(-) (limited to 'docs/model-api.txt') diff --git a/docs/model-api.txt b/docs/model-api.txt index 4e7b5c3096..4accad122a 100644 --- a/docs/model-api.txt +++ b/docs/model-api.txt @@ -12,8 +12,6 @@ The basics: * Each attribute of the model represents a database field. * Model metadata (non-field information) goes in an inner class named ``Meta``. - * Metadata used for Django's admin site goes into an inner class named - ``Admin``. * With all of this, Django gives you an automatically-generated database-access API, which is explained in the `Database API reference`_. @@ -425,18 +423,6 @@ not specified, Django will use a default length of 50. Implies ``db_index=True``. -Accepts an extra option, ``prepopulate_from``, which is a list of fields -from which to auto-populate the slug, via JavaScript, in the object's admin -form:: - - models.SlugField(prepopulate_from=("pre_name", "name")) - -``prepopulate_from`` doesn't accept DateTimeFields, ForeignKeys nor -ManyToManyFields. - -The admin represents ``SlugField`` as an ```` (a -single-line input). - ``SmallIntegerField`` ~~~~~~~~~~~~~~~~~~~~~ @@ -665,16 +651,6 @@ unless you want to override the default primary-key behavior. ``primary_key=True`` implies ``null=False`` and ``unique=True``. Only one primary key is allowed on an object. -``radio_admin`` -~~~~~~~~~~~~~~~ - -By default, Django's admin uses a select-box interface (`` - in the admin form for this object. The value should be - ``models.HORIZONTAL`` or ``models.VERTICAL`` (i.e. - should the interface be stacked horizontally or - vertically). - ``limit_choices_to`` See the description under ``ForeignKey`` above. ``symmetrical`` Only used in the definition of ManyToManyFields on self. @@ -1255,412 +1183,6 @@ attribute is the primary key field for the model. You can read and set this value, just as you would for any other attribute, and it will update the correct field in the model. -Admin options -============= - -If you want your model to be visible to Django's admin site, give your model an -inner ``"class Admin"``, like so:: - - class Person(models.Model): - first_name = models.CharField(max_length=30) - last_name = models.CharField(max_length=30) - - class Admin: - # Admin options go here - pass - -The ``Admin`` class tells Django how to display the model in the admin site. - -Here's a list of all possible ``Admin`` options. None of these options are -required. To use an admin interface without specifying any options, use -``pass``, like so:: - - class Admin: - pass - -Adding ``class Admin`` to a model is completely optional. - -``date_hierarchy`` ------------------- - -Set ``date_hierarchy`` to the name of a ``DateField`` or ``DateTimeField`` in -your model, and the change list page will include a date-based drilldown -navigation by that field. - -Example:: - - date_hierarchy = 'pub_date' - -``fields`` ----------- - -Set ``fields`` to control the layout of admin "add" and "change" pages. - -``fields`` is a list of two-tuples, in which each two-tuple represents a -``
`` on the admin form page. (A ``
`` is a "section" of the -form.) - -The two-tuples are in the format ``(name, field_options)``, where ``name`` is a -string representing the title of the fieldset and ``field_options`` is a -dictionary of information about the fieldset, including a list of fields to be -displayed in it. - -A full example, taken from the ``django.contrib.flatpages.FlatPage`` model:: - - class Admin: - fields = ( - (None, { - 'fields': ('url', 'title', 'content', 'sites') - }), - ('Advanced options', { - 'classes': 'collapse', - 'fields' : ('enable_comments', 'registration_required', 'template_name') - }), - ) - -This results in an admin page that looks like: - - .. image:: http://media.djangoproject.com/img/doc/flatfiles_admin.png - -If ``fields`` isn't given, Django will default to displaying each field that -isn't an ``AutoField`` and has ``editable=True``, in a single fieldset, in -the same order as the fields are defined in the model. - -The ``field_options`` dictionary can have the following keys: - -``fields`` -~~~~~~~~~~ - -A tuple of field names to display in this fieldset. This key is required. - -Example:: - - { - 'fields': ('first_name', 'last_name', 'address', 'city', 'state'), - } - -To display multiple fields on the same line, wrap those fields in their own -tuple. In this example, the ``first_name`` and ``last_name`` fields will -display on the same line:: - - { - 'fields': (('first_name', 'last_name'), 'address', 'city', 'state'), - } - -``classes`` -~~~~~~~~~~~ - -A string containing extra CSS classes to apply to the fieldset. - -Example:: - - { - 'classes': 'wide', - } - -Apply multiple classes by separating them with spaces. Example:: - - { - 'classes': 'wide extrapretty', - } - -Two useful classes defined by the default admin-site stylesheet are -``collapse`` and ``wide``. Fieldsets with the ``collapse`` style will be -initially collapsed in the admin and replaced with a small "click to expand" -link. Fieldsets with the ``wide`` style will be given extra horizontal space. - -``description`` -~~~~~~~~~~~~~~~ - -A string of optional extra text to be displayed at the top of each fieldset, -under the heading of the fieldset. It's used verbatim, so you can use any HTML -and you must escape any special HTML characters (such as ampersands) yourself. - -``js`` ------- - -A list of strings representing URLs of JavaScript files to link into the admin -screen via ``