mirror of
https://github.com/jazzband/django-categories.git
synced 2026-03-16 22:30:24 +00:00
151 lines
No EOL
6.6 KiB
HTML
151 lines
No EOL
6.6 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>Getting Started — Django Categories v0.6beta1 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.6beta1',
|
|
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 Categories v0.6beta1 documentation" href="index.html" />
|
|
<link rel="next" title="Using categories in templates" href="usage.html" />
|
|
<link rel="prev" title="Django Categories v|version| documentation!" href="index.html" />
|
|
</head>
|
|
<body>
|
|
<div id="docstitle">
|
|
<p>Django Categories v0.6beta1 documentation</p>
|
|
</div>
|
|
<div id="header">
|
|
<div id="title"><h1>Getting Started</h1></div>
|
|
<ul id="headerButtons">
|
|
<li id="toc_button"><div class="headerButton"><a href="#">Table of Contents</a></div></li>
|
|
<li id="page_buttons">
|
|
<div class="headerButton"><a href="genindex.html" title="General Index" accesskey="I">index</a></div>
|
|
<div class="headerButton"><a href="usage.html" title="Using categories in templates" accesskey="N">next</a></div>
|
|
<div class="headerButton"><a href="index.html" title="Django Categories v|version| documentation!" accesskey="P">previous</a></div>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
|
|
<div id="sphinxsidebar">
|
|
<div class="sphinxsidebarwrapper">
|
|
<ul><li class="toctree-l1"><a href="index.html">Main Page</a></li></ul>
|
|
<ul class="current">
|
|
<li class="toctree-l1 current"><a class="current reference internal" href="">Getting Started</a><ul>
|
|
<li class="toctree-l2"><a class="reference internal" href="#connecting-your-model-with-django-categories">Connecting your model with Django-Categories</a></li>
|
|
</ul>
|
|
</li>
|
|
<li class="toctree-l1"><a class="reference internal" href="usage.html">Using categories in templates</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="registering_models.html">Registering Models</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="templatetags.html">Template Tags</a></li>
|
|
</ul>
|
|
|
|
<h3>This Page</h3>
|
|
<ul class="this-page-menu">
|
|
<li><a href="_sources/getting_started.txt"
|
|
rel="nofollow">Show Source</a></li>
|
|
</ul>
|
|
<div id="searchbox" style="display: none">
|
|
|
|
<form class="search" action="search.html" method="get">
|
|
<div class="search-wrapper">
|
|
<span class="search-left"></span>
|
|
<input class="prettysearch" type="text" name="q" size="18" />
|
|
<span class="search-right"> </span>
|
|
</div>
|
|
<input type="submit" value="Search" class="searchbutton" />
|
|
<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="document">
|
|
<div class="documentwrapper">
|
|
<div class="bodywrapper">
|
|
<div class="body">
|
|
|
|
<div class="section" id="getting-started">
|
|
<h1>Getting Started<a class="headerlink" href="#getting-started" title="Permalink to this headline">¶</a></h1>
|
|
<p>You can use Django Categories in two ways:</p>
|
|
<ol class="arabic">
|
|
<li><p class="first">As storage for one tree of categories, e.g.:</p>
|
|
<div class="highlight-python"><pre>Top Category 1
|
|
Subcategory 1-1
|
|
Subcategory 1-2
|
|
subcategory 1-2-1
|
|
Top Category 2
|
|
Subcategory 2-1</pre>
|
|
</div>
|
|
</li>
|
|
<li><p class="first">As a storage of several trees of categories, e.g.:</p>
|
|
<div class="highlight-python"><pre>Model 1
|
|
Category 1
|
|
Subcategory 1-1
|
|
Subcategory 1-2
|
|
subcategory 1-2-1
|
|
Category 2
|
|
Subcategory 2-1
|
|
Model 2
|
|
Category 3
|
|
Subcategory 3-1
|
|
Subcategory 3-2
|
|
subcategory 3-2-1
|
|
Category 4
|
|
Subcategory 4-1</pre>
|
|
</div>
|
|
</li>
|
|
</ol>
|
|
<p>You can’t do it as both at the same time, though.</p>
|
|
<div class="section" id="connecting-your-model-with-django-categories">
|
|
<h2>Connecting your model with Django-Categories<a class="headerlink" href="#connecting-your-model-with-django-categories" title="Permalink to this headline">¶</a></h2>
|
|
<p>Because there are a few additional methods and attributes that your model needs, you can’t simply create a <tt class="docutils literal"><span class="pre">ForeignKey</span></tt> to <tt class="docutils literal"><span class="pre">Category</span></tt>, even though that is eventually what happens.</p>
|
|
<p>You add a many-to-one or many-to-many relationship with Django Categories using the <a class="reference internal" href="registering_models.html#register_fk" title="register_fk"><tt class="xref py py-func docutils literal"><span class="pre">register_fk()</span></tt></a> and <a class="reference internal" href="registering_models.html#register_m2m" title="register_m2m"><tt class="xref py py-func docutils literal"><span class="pre">register_m2m()</span></tt></a> methods respectively. For example, if you added in your <tt class="docutils literal"><span class="pre">models.py</span></tt>:</p>
|
|
<div class="highlight-python"><div class="highlight"><pre><span class="kn">import</span> <span class="nn">categories</span>
|
|
<span class="n">categories</span><span class="o">.</span><span class="n">register_fk</span><span class="p">(</span><span class="n">MyModel</span><span class="p">)</span>
|
|
</pre></div>
|
|
</div>
|
|
<p><tt class="docutils literal"><span class="pre">MyModel</span></tt> would have a <tt class="docutils literal"><span class="pre">ForeignKey</span></tt> named <tt class="docutils literal"><span class="pre">category</span></tt></p>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="footer">
|
|
<p>
|
|
© Copyright 2010, CoreyOordt.
|
|
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0.5.
|
|
</p>
|
|
</div>
|
|
<div class="clearer"></div>
|
|
</div>
|
|
<div id="breadcrumbs">
|
|
Getting Started
|
|
</ul>
|
|
</div>
|
|
<script type="text/javascript" charset="utf-8" src="_static/toc.js"></script>
|
|
</body>
|
|
</html> |