mirror of
https://github.com/django/django.git
synced 2025-08-04 02:48:35 +00:00
git-svn-id: http://code.djangoproject.com/svn/django/trunk@10303 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
15becf23a9
commit
516051bfd2
24 changed files with 206 additions and 48 deletions
|
@ -832,8 +832,17 @@ It is important you use a ``ModelForm`` here otherwise things can break. See the
|
|||
============================
|
||||
|
||||
The admin interface has the ability to edit models on the same page as a
|
||||
parent model. These are called inlines. You can add them to a model by
|
||||
specifying them in a ``ModelAdmin.inlines`` attribute::
|
||||
parent model. These are called inlines. Suppose you have these two models::
|
||||
|
||||
class Author(models.Model):
|
||||
name = models.CharField(max_length=100)
|
||||
|
||||
class Book(models.Model):
|
||||
author = models.ForeignKey(Author)
|
||||
title = models.CharField(max_length=100)
|
||||
|
||||
You can edit the books authored by an author on the author page. You add
|
||||
inlines to a model by specifying them in a ``ModelAdmin.inlines``::
|
||||
|
||||
class BookInline(admin.TabularInline):
|
||||
model = Book
|
||||
|
@ -1165,7 +1174,7 @@ Hooking ``AdminSite`` instances into your URLconf
|
|||
|
||||
The last step in setting up the Django admin is to hook your ``AdminSite``
|
||||
instance into your URLconf. Do this by pointing a given URL at the
|
||||
``AdminSite.root`` method.
|
||||
``AdminSite.urls`` method.
|
||||
|
||||
In this example, we register the default ``AdminSite`` instance
|
||||
``django.contrib.admin.site`` at the URL ``/admin/`` ::
|
||||
|
|
|
@ -155,9 +155,10 @@ A complete form might look like::
|
|||
{% get_comment_form for event as form %}
|
||||
<form action="{% comment_form_target %}" method="POST">
|
||||
{{ form }}
|
||||
<p class="submit">
|
||||
<input type="submit" name="preview" class="submit-post" value="Preview">
|
||||
</p>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td><input type="submit" name="preview" class="submit-post" value="Preview"></td>
|
||||
</tr>
|
||||
</form>
|
||||
|
||||
Be sure to read the `notes on the comment form`_, below, for some special
|
||||
|
|
|
@ -324,6 +324,14 @@ same types of lookups manually::
|
|||
... object_id=b.id)
|
||||
[<TaggedItem: django>, <TaggedItem: python>]
|
||||
|
||||
Note that if the model with a :class:`~django.contrib.contenttypes.generic.GenericForeignKey`
|
||||
that you're referring to uses a non-default value for ``ct_field`` or ``fk_field``
|
||||
(e.g. the :mod:`django.contrib.comments` app uses ``ct_field="object_pk"``),
|
||||
you'll need to pass ``content_type_field`` and ``object_id_field`` to
|
||||
:class:`~django.contrib.contenttypes.generic.GenericRelation`.::
|
||||
|
||||
comments = generic.GenericRelation(Comment, content_type_field="content_type", object_id_field="object_pk")
|
||||
|
||||
Note that if you delete an object that has a
|
||||
:class:`~django.contrib.contenttypes.generic.GenericRelation`, any objects
|
||||
which have a :class:`~django.contrib.contenttypes.generic.GenericForeignKey`
|
||||
|
|
|
@ -290,7 +290,7 @@ Advanced FormWizard methods
|
|||
.. method:: FormWizard.render_template
|
||||
|
||||
Renders the template for the given step, returning an
|
||||
:class:`~django.http.HttpResponseRedirect` object.
|
||||
:class:`~django.http.HttpResponse` object.
|
||||
|
||||
Override this method if you want to add a custom context, return a different
|
||||
MIME type, etc. If you only need to override the template name, use
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue