Sophie

Sophie

distrib > Fedora > 20 > i386 > by-pkgid > 422242acff54b9373d7d4b7f73232ce1 > files > 482

python3-django-doc-1.6.7-1.fc20.noarch.rpm


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
    <title>FAQ: The admin &mdash; Django 1.6.7 documentation</title>
    
    <link rel="stylesheet" href="../_static/default.css" type="text/css" />
    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
    
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    '../',
        VERSION:     '1.6.7',
        COLLAPSE_INDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true
      };
    </script>
    <script type="text/javascript" src="../_static/jquery.js"></script>
    <script type="text/javascript" src="../_static/underscore.js"></script>
    <script type="text/javascript" src="../_static/doctools.js"></script>
    <link rel="top" title="Django 1.6.7 documentation" href="../index.html" />
    <link rel="up" title="Django FAQ" href="index.html" />
    <link rel="next" title="FAQ: Contributing code" href="contributing.html" />
    <link rel="prev" title="FAQ: Databases and models" href="models.html" />



 
<script type="text/javascript" src="../templatebuiltins.js"></script>
<script type="text/javascript">
(function($) {
    if (!django_template_builtins) {
       // templatebuiltins.js missing, do nothing.
       return;
    }
    $(document).ready(function() {
        // Hyperlink Django template tags and filters
        var base = "../ref/templates/builtins.html";
        if (base == "#") {
            // Special case for builtins.html itself
            base = "";
        }
        // Tags are keywords, class '.k'
        $("div.highlight\\-html\\+django span.k").each(function(i, elem) {
             var tagname = $(elem).text();
             if ($.inArray(tagname, django_template_builtins.ttags) != -1) {
                 var fragment = tagname.replace(/_/, '-');
                 $(elem).html("<a href='" + base + "#" + fragment + "'>" + tagname + "</a>");
             }
        });
        // Filters are functions, class '.nf'
        $("div.highlight\\-html\\+django span.nf").each(function(i, elem) {
             var filtername = $(elem).text();
             if ($.inArray(filtername, django_template_builtins.tfilters) != -1) {
                 var fragment = filtername.replace(/_/, '-');
                 $(elem).html("<a href='" + base + "#" + fragment + "'>" + filtername + "</a>");
             }
        });
    });
})(jQuery);
</script>


  </head>
  <body>

    <div class="document">
  <div id="custom-doc" class="yui-t6">
    <div id="hd">
      <h1><a href="../index.html">Django 1.6.7 documentation</a></h1>
      <div id="global-nav">
        <a title="Home page" href="../index.html">Home</a>  |
        <a title="Table of contents" href="../contents.html">Table of contents</a>  |
        <a title="Global index" href="../genindex.html">Index</a>  |
        <a title="Module index" href="../py-modindex.html">Modules</a>
      </div>
      <div class="nav">
    &laquo; <a href="models.html" title="FAQ: Databases and models">previous</a> 
     |
    <a href="index.html" title="Django FAQ" accesskey="U">up</a>
   |
    <a href="contributing.html" title="FAQ: Contributing code">next</a> &raquo;</div>
    </div>
    
    <div id="bd">
      <div id="yui-main">
        <div class="yui-b">
          <div class="yui-g" id="faq-admin">
            
  <div class="section" id="s-faq-the-admin">
<span id="faq-the-admin"></span><h1>FAQ: The admin<a class="headerlink" href="#faq-the-admin" title="Permalink to this headline">¶</a></h1>
<div class="section" id="s-i-can-t-log-in-when-i-enter-a-valid-username-and-password-it-just-brings-up-the-login-page-again-with-no-error-messages">
<span id="i-can-t-log-in-when-i-enter-a-valid-username-and-password-it-just-brings-up-the-login-page-again-with-no-error-messages"></span><h2>I can&#8217;t log in. When I enter a valid username and password, it just brings up the login page again, with no error messages.<a class="headerlink" href="#i-can-t-log-in-when-i-enter-a-valid-username-and-password-it-just-brings-up-the-login-page-again-with-no-error-messages" title="Permalink to this headline">¶</a></h2>
<p>The login cookie isn&#8217;t being set correctly, because the domain of the cookie
sent out by Django doesn&#8217;t match the domain in your browser. Try these two
things:</p>
<ul class="simple">
<li>Set the <a class="reference internal" href="../ref/settings.html#std:setting-SESSION_COOKIE_DOMAIN"><tt class="xref std std-setting docutils literal"><span class="pre">SESSION_COOKIE_DOMAIN</span></tt></a> setting in your admin config
file to match your domain. For example, if you&#8217;re going to
&#8220;<a class="reference external" href="http://www.example.com/admin/">http://www.example.com/admin/</a>&#8221; in your browser, in &#8220;myproject.settings&#8221; you
should set <a class="reference internal" href="../ref/settings.html#std:setting-SESSION_COOKIE_DOMAIN"><tt class="xref std std-setting docutils literal"><span class="pre">SESSION_COOKIE_DOMAIN</span></tt></a> = &#8216;www.example.com&#8217;.</li>
<li>Some browsers (Firefox?) don&#8217;t like to accept cookies from domains that
don&#8217;t have dots in them. If you&#8217;re running the admin site on &#8220;localhost&#8221;
or another domain that doesn&#8217;t have a dot in it, try going to
&#8220;localhost.localdomain&#8221; or &#8220;127.0.0.1&#8221;. And set
<a class="reference internal" href="../ref/settings.html#std:setting-SESSION_COOKIE_DOMAIN"><tt class="xref std std-setting docutils literal"><span class="pre">SESSION_COOKIE_DOMAIN</span></tt></a> accordingly.</li>
</ul>
</div>
<div class="section" id="s-i-can-t-log-in-when-i-enter-a-valid-username-and-password-it-brings-up-the-login-page-again-with-a-please-enter-a-correct-username-and-password-error">
<span id="i-can-t-log-in-when-i-enter-a-valid-username-and-password-it-brings-up-the-login-page-again-with-a-please-enter-a-correct-username-and-password-error"></span><h2>I can&#8217;t log in. When I enter a valid username and password, it brings up the login page again, with a &#8220;Please enter a correct username and password&#8221; error.<a class="headerlink" href="#i-can-t-log-in-when-i-enter-a-valid-username-and-password-it-brings-up-the-login-page-again-with-a-please-enter-a-correct-username-and-password-error" title="Permalink to this headline">¶</a></h2>
<p>If you&#8217;re sure your username and password are correct, make sure your user
account has <a class="reference internal" href="../ref/contrib/auth.html#django.contrib.auth.models.User.is_active" title="django.contrib.auth.models.User.is_active"><tt class="xref py py-attr docutils literal"><span class="pre">is_active</span></tt></a> and
<a class="reference internal" href="../ref/contrib/auth.html#django.contrib.auth.models.User.is_staff" title="django.contrib.auth.models.User.is_staff"><tt class="xref py py-attr docutils literal"><span class="pre">is_staff</span></tt></a> set to True. The admin site
only allows access to users with those two fields both set to True.</p>
</div>
<div class="section" id="s-how-do-i-automatically-set-a-field-s-value-to-the-user-who-last-edited-the-object-in-the-admin">
<span id="how-do-i-automatically-set-a-field-s-value-to-the-user-who-last-edited-the-object-in-the-admin"></span><h2>How do I automatically set a field&#8217;s value to the user who last edited the object in the admin?<a class="headerlink" href="#how-do-i-automatically-set-a-field-s-value-to-the-user-who-last-edited-the-object-in-the-admin" title="Permalink to this headline">¶</a></h2>
<p>The <a class="reference internal" href="../ref/contrib/admin/index.html#django.contrib.admin.ModelAdmin" title="django.contrib.admin.ModelAdmin"><tt class="xref py py-class docutils literal"><span class="pre">ModelAdmin</span></tt></a> class provides customization hooks
that allow you to transform an object as it saved, using details from the
request. By extracting the current user from the request, and customizing the
<a class="reference internal" href="../ref/contrib/admin/index.html#django.contrib.admin.ModelAdmin.save_model" title="django.contrib.admin.ModelAdmin.save_model"><tt class="xref py py-meth docutils literal"><span class="pre">save_model()</span></tt></a> hook, you can update an
object to reflect the user that edited it. See <a class="reference internal" href="../ref/contrib/admin/index.html#model-admin-methods"><em>the documentation on
ModelAdmin methods</em></a> for an example.</p>
</div>
<div class="section" id="s-how-do-i-limit-admin-access-so-that-objects-can-only-be-edited-by-the-users-who-created-them">
<span id="how-do-i-limit-admin-access-so-that-objects-can-only-be-edited-by-the-users-who-created-them"></span><h2>How do I limit admin access so that objects can only be edited by the users who created them?<a class="headerlink" href="#how-do-i-limit-admin-access-so-that-objects-can-only-be-edited-by-the-users-who-created-them" title="Permalink to this headline">¶</a></h2>
<p>The <a class="reference internal" href="../ref/contrib/admin/index.html#django.contrib.admin.ModelAdmin" title="django.contrib.admin.ModelAdmin"><tt class="xref py py-class docutils literal"><span class="pre">ModelAdmin</span></tt></a> class also provides customization
hooks that allow you to control the visibility and editability of objects in the
admin. Using the same trick of extracting the user from the request, the
<a class="reference internal" href="../ref/contrib/admin/index.html#django.contrib.admin.ModelAdmin.get_queryset" title="django.contrib.admin.ModelAdmin.get_queryset"><tt class="xref py py-meth docutils literal"><span class="pre">get_queryset()</span></tt></a> and
<a class="reference internal" href="../ref/contrib/admin/index.html#django.contrib.admin.ModelAdmin.has_change_permission" title="django.contrib.admin.ModelAdmin.has_change_permission"><tt class="xref py py-meth docutils literal"><span class="pre">has_change_permission()</span></tt></a> can be used to
control the visibility and editability of objects in the admin.</p>
</div>
<div class="section" id="s-my-admin-site-css-and-images-showed-up-fine-using-the-development-server-but-they-re-not-displaying-when-using-mod-wsgi">
<span id="my-admin-site-css-and-images-showed-up-fine-using-the-development-server-but-they-re-not-displaying-when-using-mod-wsgi"></span><h2>My admin-site CSS and images showed up fine using the development server, but they&#8217;re not displaying when using mod_wsgi.<a class="headerlink" href="#my-admin-site-css-and-images-showed-up-fine-using-the-development-server-but-they-re-not-displaying-when-using-mod-wsgi" title="Permalink to this headline">¶</a></h2>
<p>See <a class="reference internal" href="../howto/deployment/wsgi/modwsgi.html#serving-the-admin-files"><em>serving the admin files</em></a>
in the &#8220;How to use Django with mod_wsgi&#8221; documentation.</p>
</div>
<div class="section" id="s-my-list-filter-contains-a-manytomanyfield-but-the-filter-doesn-t-display">
<span id="my-list-filter-contains-a-manytomanyfield-but-the-filter-doesn-t-display"></span><h2>My &#8220;list_filter&#8221; contains a ManyToManyField, but the filter doesn&#8217;t display.<a class="headerlink" href="#my-list-filter-contains-a-manytomanyfield-but-the-filter-doesn-t-display" title="Permalink to this headline">¶</a></h2>
<p>Django won&#8217;t bother displaying the filter for a <tt class="docutils literal"><span class="pre">ManyToManyField</span></tt> if there
are fewer than two related objects.</p>
<p>For example, if your <a class="reference internal" href="../ref/contrib/admin/index.html#django.contrib.admin.ModelAdmin.list_filter" title="django.contrib.admin.ModelAdmin.list_filter"><tt class="xref py py-attr docutils literal"><span class="pre">list_filter</span></tt></a>
includes <a class="reference internal" href="../ref/contrib/sites.html"><em>sites</em></a>, and there&#8217;s only one site in your
database, it won&#8217;t display a &#8220;Site&#8221; filter. In that case, filtering by site
would be meaningless.</p>
</div>
<div class="section" id="s-some-objects-aren-t-appearing-in-the-admin">
<span id="some-objects-aren-t-appearing-in-the-admin"></span><h2>Some objects aren&#8217;t appearing in the admin.<a class="headerlink" href="#some-objects-aren-t-appearing-in-the-admin" title="Permalink to this headline">¶</a></h2>
<p>Inconsistent row counts may be caused by missing foreign key values or a
foreign key field incorrectly set to <a class="reference internal" href="../ref/models/fields.html#django.db.models.Field.null" title="django.db.models.Field.null"><tt class="xref py py-attr docutils literal"><span class="pre">null=False</span></tt></a>. If you have a record with a
<a class="reference internal" href="../ref/models/fields.html#django.db.models.ForeignKey" title="django.db.models.ForeignKey"><tt class="xref py py-class docutils literal"><span class="pre">ForeignKey</span></tt></a> pointing to a non-existent object and
that foreign key is included is
<a class="reference internal" href="../ref/contrib/admin/index.html#django.contrib.admin.ModelAdmin.list_display" title="django.contrib.admin.ModelAdmin.list_display"><tt class="xref py py-attr docutils literal"><span class="pre">list_display</span></tt></a>, the record will not be
shown in the admin changelist because the Django model is declaring an
integrity constraint that is not implemented at the database level.</p>
</div>
<div class="section" id="s-how-can-i-customize-the-functionality-of-the-admin-interface">
<span id="how-can-i-customize-the-functionality-of-the-admin-interface"></span><h2>How can I customize the functionality of the admin interface?<a class="headerlink" href="#how-can-i-customize-the-functionality-of-the-admin-interface" title="Permalink to this headline">¶</a></h2>
<p>You&#8217;ve got several options. If you want to piggyback on top of an add/change
form that Django automatically generates, you can attach arbitrary JavaScript
modules to the page via the model&#8217;s class Admin <a class="reference internal" href="../ref/contrib/admin/index.html#modeladmin-asset-definitions"><em>js parameter</em></a>. That parameter is a list of URLs, as strings,
pointing to JavaScript modules that will be included within the admin form via
a <tt class="docutils literal"><span class="pre">&lt;script&gt;</span></tt> tag.</p>
<p>If you want more flexibility than simply tweaking the auto-generated forms,
feel free to write custom views for the admin. The admin is powered by Django
itself, and you can write custom views that hook into the authentication
system, check permissions and do whatever else they need to do.</p>
<p>If you want to customize the look-and-feel of the admin interface, read the
next question.</p>
</div>
<div class="section" id="s-the-dynamically-generated-admin-site-is-ugly-how-can-i-change-it">
<span id="the-dynamically-generated-admin-site-is-ugly-how-can-i-change-it"></span><h2>The dynamically-generated admin site is ugly! How can I change it?<a class="headerlink" href="#the-dynamically-generated-admin-site-is-ugly-how-can-i-change-it" title="Permalink to this headline">¶</a></h2>
<p>We like it, but if you don&#8217;t agree, you can modify the admin site&#8217;s
presentation by editing the CSS stylesheet and/or associated image files. The
site is built using semantic HTML and plenty of CSS hooks, so any changes you&#8217;d
like to make should be possible by editing the stylesheet.</p>
</div>
<div class="section" id="s-what-browsers-are-supported-for-using-the-admin">
<span id="what-browsers-are-supported-for-using-the-admin"></span><h2>What browsers are supported for using the admin?<a class="headerlink" href="#what-browsers-are-supported-for-using-the-admin" title="Permalink to this headline">¶</a></h2>
<p>The admin provides a fully-functional experience to <a class="reference external" href="http://yuilibrary.com/yui/docs/tutorials/gbs/">YUI&#8217;s A-grade</a> browsers,
with the notable exception of IE6, which is not supported.</p>
<p>There <em>may</em> be minor stylistic differences between supported browsers—for
example, some browsers may not support rounded corners. These are considered
acceptable variations in rendering.</p>
</div>
</div>


          </div>         
        </div>
      </div>
      
        
          <div class="yui-b" id="sidebar">
            
      <div class="sphinxsidebar">
        <div class="sphinxsidebarwrapper">
  <h3><a href="../contents.html">Table Of Contents</a></h3>
  <ul>
<li><a class="reference internal" href="#">FAQ: The admin</a><ul>
<li><a class="reference internal" href="#i-can-t-log-in-when-i-enter-a-valid-username-and-password-it-just-brings-up-the-login-page-again-with-no-error-messages">I can&#8217;t log in. When I enter a valid username and password, it just brings up the login page again, with no error messages.</a></li>
<li><a class="reference internal" href="#i-can-t-log-in-when-i-enter-a-valid-username-and-password-it-brings-up-the-login-page-again-with-a-please-enter-a-correct-username-and-password-error">I can&#8217;t log in. When I enter a valid username and password, it brings up the login page again, with a &#8220;Please enter a correct username and password&#8221; error.</a></li>
<li><a class="reference internal" href="#how-do-i-automatically-set-a-field-s-value-to-the-user-who-last-edited-the-object-in-the-admin">How do I automatically set a field&#8217;s value to the user who last edited the object in the admin?</a></li>
<li><a class="reference internal" href="#how-do-i-limit-admin-access-so-that-objects-can-only-be-edited-by-the-users-who-created-them">How do I limit admin access so that objects can only be edited by the users who created them?</a></li>
<li><a class="reference internal" href="#my-admin-site-css-and-images-showed-up-fine-using-the-development-server-but-they-re-not-displaying-when-using-mod-wsgi">My admin-site CSS and images showed up fine using the development server, but they&#8217;re not displaying when using mod_wsgi.</a></li>
<li><a class="reference internal" href="#my-list-filter-contains-a-manytomanyfield-but-the-filter-doesn-t-display">My &#8220;list_filter&#8221; contains a ManyToManyField, but the filter doesn&#8217;t display.</a></li>
<li><a class="reference internal" href="#some-objects-aren-t-appearing-in-the-admin">Some objects aren&#8217;t appearing in the admin.</a></li>
<li><a class="reference internal" href="#how-can-i-customize-the-functionality-of-the-admin-interface">How can I customize the functionality of the admin interface?</a></li>
<li><a class="reference internal" href="#the-dynamically-generated-admin-site-is-ugly-how-can-i-change-it">The dynamically-generated admin site is ugly! How can I change it?</a></li>
<li><a class="reference internal" href="#what-browsers-are-supported-for-using-the-admin">What browsers are supported for using the admin?</a></li>
</ul>
</li>
</ul>

  <h3>Browse</h3>
  <ul>
    
      <li>Prev: <a href="models.html">FAQ: Databases and models</a></li>
    
    
      <li>Next: <a href="contributing.html">FAQ: Contributing code</a></li>
    
  </ul>
  <h3>You are here:</h3>
  <ul>
      <li>
        <a href="../index.html">Django 1.6.7 documentation</a>
        
          <ul><li><a href="index.html">Django FAQ</a>
        
        <ul><li>FAQ: The admin</li></ul>
        </li></ul>
      </li>
  </ul>  

  <h3>This Page</h3>
  <ul class="this-page-menu">
    <li><a href="../_sources/faq/admin.txt"
           rel="nofollow">Show Source</a></li>
  </ul>
<div id="searchbox" style="display: none">
  <h3>Quick search</h3>
    <form class="search" action="../search.html" method="get">
      <input type="text" name="q" />
      <input type="submit" value="Go" />
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>
    <p class="searchtip" style="font-size: 90%">
    Enter search terms or a module, class or function name.
    </p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
              <h3>Last update:</h3>
              <p class="topless">Sep 26, 2014</p>
          </div> 
        
      
    </div>
    
    <div id="ft">
      <div class="nav">
    &laquo; <a href="models.html" title="FAQ: Databases and models">previous</a> 
     |
    <a href="index.html" title="Django FAQ" accesskey="U">up</a>
   |
    <a href="contributing.html" title="FAQ: Contributing code">next</a> &raquo;</div>
    </div>
  </div>

      <div class="clearer"></div>
    </div>
  </body>
</html>