{"title":"The Django admin documentation generator","version":"1.9","locale":"ja","docname":"ref/contrib/admin/admindocs","url":"/ja/1.9/ref/contrib/admin/admindocs/","canonical":"https://djangodocs.dev/ja/1.9/ref/contrib/admin/admindocs/","summary":"Django's admindocs app pulls documentation from the docstrings of models, views, template tags, and template filters for any app in INSTALLED_APPS and makes that…","html":"<span id=\"the-django-admin-documentation-generator\"></span><h1>The Django admin documentation generator<a class=\"heading-anchor\" href=\"#module-django.contrib.admindocs\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h1>\n<p>Django's <a class=\"reference internal\" href=\"#module-django.contrib.admindocs\" title=\"django.contrib.admindocs: Django's admin documentation generator.\"><code class=\"xref py py-mod docutils literal notranslate\"><span class=\"pre\">admindocs</span></code></a> app pulls documentation from the\ndocstrings of models, views, template tags, and template filters for any app in\n<a class=\"reference internal\" href=\"/ja/1.9/ref/settings/#std-setting-INSTALLED_APPS\"><code class=\"xref std std-setting docutils literal notranslate\"><span class=\"pre\">INSTALLED_APPS</span></code></a> and makes that documentation available from the\n<a class=\"reference internal\" href=\"/ja/1.9/ref/contrib/admin/#module-django.contrib.admin\" title=\"django.contrib.admin: Django's admin site.\"><code class=\"xref py py-mod docutils literal notranslate\"><span class=\"pre\">Django</span> <span class=\"pre\">admin</span></code></a>.</p>\n<section id=\"overview\">\n<h2>Overview<a class=\"heading-anchor\" href=\"#overview\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p>To activate the <a class=\"reference internal\" href=\"#module-django.contrib.admindocs\" title=\"django.contrib.admindocs: Django's admin documentation generator.\"><code class=\"xref py py-mod docutils literal notranslate\"><span class=\"pre\">admindocs</span></code></a>, you will need to do\nthe following:</p>\n<ul class=\"simple\">\n<li><p>Add <a class=\"reference internal\" href=\"#module-django.contrib.admindocs\" title=\"django.contrib.admindocs: Django's admin documentation generator.\"><code class=\"xref py py-mod docutils literal notranslate\"><span class=\"pre\">django.contrib.admindocs</span></code></a> to your <a class=\"reference internal\" href=\"/ja/1.9/ref/settings/#std-setting-INSTALLED_APPS\"><code class=\"xref std std-setting docutils literal notranslate\"><span class=\"pre\">INSTALLED_APPS</span></code></a>.</p></li>\n<li><p>Add <code class=\"docutils literal notranslate\"><span class=\"pre\">url(r'^admin/doc/',</span> <span class=\"pre\">include('django.contrib.admindocs.urls'))</span></code> to\nyour <code class=\"docutils literal notranslate\"><span class=\"pre\">urlpatterns</span></code>. Make sure it's included <em>before</em> the\n<code class=\"docutils literal notranslate\"><span class=\"pre\">r'^admin/'</span></code> entry, so that requests to <code class=\"docutils literal notranslate\"><span class=\"pre\">/admin/doc/</span></code> don't get\nhandled by the latter entry.</p></li>\n<li><p>Install the docutils Python module (<a class=\"reference external\" href=\"http://docutils.sf.net/\">http://docutils.sf.net/</a>).</p></li>\n<li><p><strong>Optional:</strong> Using the admindocs bookmarklets requires\n<code class=\"docutils literal notranslate\"><span class=\"pre\">django.contrib.admindocs.middleware.XViewMiddleware</span></code> to be installed.</p></li>\n</ul>\n<p>Once those steps are complete, you can start browsing the documentation by\ngoing to your admin interface and clicking the &quot;Documentation&quot; link in the\nupper right of the page.</p>\n</section>\n<section id=\"documentation-helpers\">\n<h2>Documentation helpers<a class=\"heading-anchor\" href=\"#documentation-helpers\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p>The following special markup can be used in your docstrings to easily create\nhyperlinks to other components:</p>\n<div class=\"table-scroll\" role=\"region\" tabindex=\"0\" aria-label=\"Table\"><table class=\"docutils align-default\">\n<thead>\n<tr class=\"row-odd\"><th class=\"head\"><p>Django Component</p></th>\n<th class=\"head\"><p>reStructuredText roles</p></th>\n</tr>\n</thead>\n<tbody>\n<tr class=\"row-even\"><td><p>Models</p></td>\n<td><p><code class=\"docutils literal notranslate\"><span class=\"pre\">:model:`app_label.ModelName`</span></code></p></td>\n</tr>\n<tr class=\"row-odd\"><td><p>Views</p></td>\n<td><p><code class=\"docutils literal notranslate\"><span class=\"pre\">:view:`app_label.view_name`</span></code></p></td>\n</tr>\n<tr class=\"row-even\"><td><p>Template tags</p></td>\n<td><p><code class=\"docutils literal notranslate\"><span class=\"pre\">:tag:`tagname`</span></code></p></td>\n</tr>\n<tr class=\"row-odd\"><td><p>Template filters</p></td>\n<td><p><code class=\"docutils literal notranslate\"><span class=\"pre\">:filter:`filtername`</span></code></p></td>\n</tr>\n<tr class=\"row-even\"><td><p>Templates</p></td>\n<td><p><code class=\"docutils literal notranslate\"><span class=\"pre\">:template:`path/to/template.html`</span></code></p></td>\n</tr>\n</tbody>\n</table>\n</div>\n</section>\n<section id=\"model-reference\">\n<h2>Model reference<a class=\"heading-anchor\" href=\"#model-reference\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p>The <strong>models</strong> section of the <code class=\"docutils literal notranslate\"><span class=\"pre\">admindocs</span></code> page describes each model in the\nsystem along with all the fields and methods available on it. Relationships\nto other models appear as hyperlinks. Descriptions are pulled from <code class=\"docutils literal notranslate\"><span class=\"pre\">help_text</span></code>\nattributes on fields or from docstrings on model methods.</p>\n<aside class=\"version-note version-changed\" data-version=\"1.9\">\n<p class=\"version-note-title\">Changed in Django 1.9</p><p>The <strong>models</strong> section of the <code class=\"docutils literal notranslate\"><span class=\"pre\">admindocs</span></code> now describes methods that take\narguments as well. In previous versions it was restricted to methods\nwithout arguments.</p>\n</aside>\n<p>A model with useful documentation might look like this:</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code><span class=\"k\">class</span><span class=\"w\"> </span><span class=\"nc\">BlogEntry</span><span class=\"p\">(</span><span class=\"n\">models</span><span class=\"o\">.</span><span class=\"n\">Model</span><span class=\"p\">):</span>\n<span class=\"w\">    </span><span class=\"sd\">&quot;&quot;&quot;</span>\n<span class=\"sd\">    Stores a single blog entry, related to :model:`blog.Blog` and</span>\n<span class=\"sd\">    :model:`auth.User`.</span>\n<span class=\"sd\">    &quot;&quot;&quot;</span>\n    <span class=\"n\">slug</span> <span class=\"o\">=</span> <span class=\"n\">models</span><span class=\"o\">.</span><span class=\"n\">SlugField</span><span class=\"p\">(</span><span class=\"n\">help_text</span><span class=\"o\">=</span><span class=\"s2\">&quot;A short label, generally used in URLs.&quot;</span><span class=\"p\">)</span>\n    <span class=\"n\">author</span> <span class=\"o\">=</span> <span class=\"n\">models</span><span class=\"o\">.</span><span class=\"n\">ForeignKey</span><span class=\"p\">(</span>\n        <span class=\"n\">User</span><span class=\"p\">,</span>\n        <span class=\"n\">models</span><span class=\"o\">.</span><span class=\"n\">SET_NULL</span><span class=\"p\">,</span>\n        <span class=\"n\">blank</span><span class=\"o\">=</span><span class=\"kc\">True</span><span class=\"p\">,</span> <span class=\"n\">null</span><span class=\"o\">=</span><span class=\"kc\">True</span><span class=\"p\">,</span>\n    <span class=\"p\">)</span>\n    <span class=\"n\">blog</span> <span class=\"o\">=</span> <span class=\"n\">models</span><span class=\"o\">.</span><span class=\"n\">ForeignKey</span><span class=\"p\">(</span><span class=\"n\">Blog</span><span class=\"p\">,</span> <span class=\"n\">models</span><span class=\"o\">.</span><span class=\"n\">CASCADE</span><span class=\"p\">)</span>\n    <span class=\"o\">...</span>\n\n    <span class=\"k\">def</span><span class=\"w\"> </span><span class=\"nf\">publish</span><span class=\"p\">(</span><span class=\"bp\">self</span><span class=\"p\">):</span>\n<span class=\"w\">        </span><span class=\"sd\">&quot;&quot;&quot;Makes the blog entry live on the site.&quot;&quot;&quot;</span>\n        <span class=\"o\">...</span>\n</code></pre></div>\n</section>\n<section id=\"view-reference\">\n<h2>View reference<a class=\"heading-anchor\" href=\"#view-reference\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p>Each URL in your site has a separate entry in the <code class=\"docutils literal notranslate\"><span class=\"pre\">admindocs</span></code> page, and\nclicking on a given URL will show you the corresponding view. Helpful things\nyou can document in your view function docstrings include:</p>\n<ul class=\"simple\">\n<li><p>A short description of what the view does.</p></li>\n<li><p>The <strong>context</strong>, or a list of variables available in the view's template.</p></li>\n<li><p>The name of the template or templates that are used for that view.</p></li>\n</ul>\n<p>For example:</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code><span class=\"kn\">from</span><span class=\"w\"> </span><span class=\"nn\">django.shortcuts</span><span class=\"w\"> </span><span class=\"kn\">import</span> <span class=\"n\">render</span>\n\n<span class=\"kn\">from</span><span class=\"w\"> </span><span class=\"nn\">myapp.models</span><span class=\"w\"> </span><span class=\"kn\">import</span> <span class=\"n\">MyModel</span>\n\n<span class=\"k\">def</span><span class=\"w\"> </span><span class=\"nf\">my_view</span><span class=\"p\">(</span><span class=\"n\">request</span><span class=\"p\">,</span> <span class=\"n\">slug</span><span class=\"p\">):</span>\n<span class=\"w\">    </span><span class=\"sd\">&quot;&quot;&quot;</span>\n<span class=\"sd\">    Display an individual :model:`myapp.MyModel`.</span>\n\n<span class=\"sd\">    **Context**</span>\n\n<span class=\"sd\">    ``mymodel``</span>\n<span class=\"sd\">        An instance of :model:`myapp.MyModel`.</span>\n\n<span class=\"sd\">    **Template:**</span>\n\n<span class=\"sd\">    :template:`myapp/my_template.html`</span>\n<span class=\"sd\">    &quot;&quot;&quot;</span>\n    <span class=\"n\">context</span> <span class=\"o\">=</span> <span class=\"p\">{</span><span class=\"s1\">&#39;mymodel&#39;</span><span class=\"p\">:</span> <span class=\"n\">MyModel</span><span class=\"o\">.</span><span class=\"n\">objects</span><span class=\"o\">.</span><span class=\"n\">get</span><span class=\"p\">(</span><span class=\"n\">slug</span><span class=\"o\">=</span><span class=\"n\">slug</span><span class=\"p\">)}</span>\n    <span class=\"k\">return</span> <span class=\"n\">render</span><span class=\"p\">(</span><span class=\"n\">request</span><span class=\"p\">,</span> <span class=\"s1\">&#39;myapp/my_template.html&#39;</span><span class=\"p\">,</span> <span class=\"n\">context</span><span class=\"p\">)</span>\n</code></pre></div>\n</section>\n<section id=\"template-tags-and-filters-reference\">\n<h2>Template tags and filters reference<a class=\"heading-anchor\" href=\"#template-tags-and-filters-reference\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p>The <strong>tags</strong> and <strong>filters</strong> <code class=\"docutils literal notranslate\"><span class=\"pre\">admindocs</span></code> sections describe all the tags and\nfilters that come with Django (in fact, the <a class=\"reference internal\" href=\"/ja/1.9/ref/templates/builtins/#ref-templates-builtins-tags\"><span class=\"std std-ref\">built-in tag reference</span></a> and <a class=\"reference internal\" href=\"/ja/1.9/ref/templates/builtins/#ref-templates-builtins-filters\"><span class=\"std std-ref\">built-in filter reference</span></a> documentation come directly from those\npages). Any tags or filters that you create or are added by a third-party app\nwill show up in these sections as well.</p>\n</section>\n<section id=\"template-reference\">\n<h2>Template reference<a class=\"heading-anchor\" href=\"#template-reference\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p>While <code class=\"docutils literal notranslate\"><span class=\"pre\">admindocs</span></code> does not include a place to document templates by\nthemselves, if you use the <code class=\"docutils literal notranslate\"><span class=\"pre\">:template:`path/to/template.html`</span></code> syntax in a\ndocstring the resulting page will verify the path of that template with\nDjango's <a class=\"reference internal\" href=\"/ja/1.9/ref/templates/api/#template-loaders\"><span class=\"std std-ref\">template loaders</span></a>. This can be a handy way to\ncheck if the specified template exists and to show where on the filesystem that\ntemplate is stored.</p>\n</section>\n<section id=\"included-bookmarklets\">\n<span id=\"admindocs-bookmarklets\"></span><h2>Included Bookmarklets<a class=\"heading-anchor\" href=\"#included-bookmarklets\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p>One bookmarklet is available from the <code class=\"docutils literal notranslate\"><span class=\"pre\">admindocs</span></code> page:</p>\n<dl class=\"simple\">\n<dt>Documentation for this page</dt><dd><p>Jumps you from any page to the documentation for the view that generates\nthat page.</p>\n</dd>\n</dl>\n<p>Using this bookmarklet requires that <code class=\"docutils literal notranslate\"><span class=\"pre\">XViewMiddleware</span></code> is installed and that\nyou are logged into the <a class=\"reference internal\" href=\"/ja/1.9/ref/contrib/admin/#module-django.contrib.admin\" title=\"django.contrib.admin: Django's admin site.\"><code class=\"xref py py-mod docutils literal notranslate\"><span class=\"pre\">Django</span> <span class=\"pre\">admin</span></code></a> as a\n<a class=\"reference internal\" href=\"/ja/1.9/ref/contrib/auth/#id0\" title=\"django.contrib.auth.models.User\"><code class=\"xref py py-class docutils literal notranslate\"><span class=\"pre\">User</span></code></a> with\n<a class=\"reference internal\" href=\"/ja/1.9/ref/contrib/auth/#django.contrib.auth.models.User.is_staff\" title=\"django.contrib.auth.models.User.is_staff\"><code class=\"xref py py-attr docutils literal notranslate\"><span class=\"pre\">is_staff</span></code></a> set to <code class=\"docutils literal notranslate\"><span class=\"pre\">True</span></code>.</p>\n</section>","rootId":"module-django.contrib.admindocs","toc":[{"title":"Overview","anchor":"overview","children":[]},{"title":"Documentation helpers","anchor":"documentation-helpers","children":[]},{"title":"Model reference","anchor":"model-reference","children":[]},{"title":"View reference","anchor":"view-reference","children":[]},{"title":"Template tags and filters reference","anchor":"template-tags-and-filters-reference","children":[]},{"title":"Template reference","anchor":"template-reference","children":[]},{"title":"Included Bookmarklets","anchor":"included-bookmarklets","children":[]}],"breadcrumbs":[{"docname":"ref/index","title":"API Reference","url":"/ja/1.9/ref/"},{"docname":"ref/contrib/index","title":"contrib packages","url":"/ja/1.9/ref/contrib/"},{"docname":"ref/contrib/admin/index","title":"The Django admin site","url":"/ja/1.9/ref/contrib/admin/"}],"prev":{"docname":"ref/contrib/admin/actions","title":"Admin actions","url":"/ja/1.9/ref/contrib/admin/actions/"},"next":{"docname":"ref/contrib/admin/javascript","title":"JavaScript customizations in the admin","url":"/ja/1.9/ref/contrib/admin/javascript/"},"formats":{"html":"/ja/1.9/ref/contrib/admin/admindocs/","markdown":"/ja/1.9/ref/contrib/admin/admindocs.md","json":"/ja/1.9/ref/contrib/admin/admindocs.json"},"source":"https://github.com/django/django/blob/stable/1.9.x/docs/ref/contrib/admin/admindocs.txt","official":"https://docs.djangoproject.com/ja/1.9/ref/contrib/admin/admindocs/","inVersions":["6.1","6.0","5.2","5.1","5.0","4.2","4.1","4.0","3.2","3.1","3.0","2.2","2.1","2.0","1.11","1.10","1.9"],"inLocales":["en","fr","ja","id","pt-br","es"]}