django-categories/docs/registering_models.html

98 lines
No EOL
3.7 KiB
HTML

<!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>Registering Models &mdash; Django Categories v0.4.4 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: '0.4.4',
COLLAPSE_MODINDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
};
</script>
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<link rel="top" title="Django Categories v0.4.4 documentation" href="index.html" />
</head>
<body>
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
accesskey="I">index</a></li>
<li><a href="index.html">Django Categories v0.4.4 documentation</a> &raquo;</li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body">
<div class="section" id="registering-models">
<h1>Registering Models<a class="headerlink" href="#registering-models" title="Permalink to this headline"></a></h1>
<p>You can register models with the</p>
<p>import categories
categories.register_fk(MyModel)</p>
<p>or</p>
<p>import categories
categories.register_m2m(MyModel)</p>
<p>If you want more than one field on a model you have to have some extra arguments</p>
<blockquote>
import categories
categories.register_fk(MyModel, &#8216;primary_category&#8217;)
categories.register_fk(MyModel, &#8216;secondary_category&#8217;, {&#8216;related_name&#8217;:&#8217;mymodel_sec_set&#8217;})</blockquote>
<p>The <tt class="docutils literal"><span class="pre">extra_args</span></tt> allows you to specify the related_name of one of the fields so it doesn&#8217;t clash.</p>
</div>
</div>
</div>
</div>
<div class="sphinxsidebar">
<div class="sphinxsidebarwrapper">
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="_sources/registering_models.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" size="18" />
<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>
<div class="clearer"></div>
</div>
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
>index</a></li>
<li><a href="index.html">Django Categories v0.4.4 documentation</a> &raquo;</li>
</ul>
</div>
<div class="footer">
&copy; Copyright 2010, CoreyOordt.
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 0.6.3.
</div>
</body>
</html>