Added Django CMS docs.
parent
b3c9fffbfa
commit
87917cfadb
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -0,0 +1,47 @@
|
||||||
|
Django-CMS Integration
|
||||||
|
======================
|
||||||
|
|
||||||
|
Django-CMS plugins use their own change form, and thus won't automatically include the necessary JavaScript for django-admin-sortable to work. Fortunately, this is easy to resolve, as the ``CMSPlugin`` class allows a change form template to be specified::
|
||||||
|
|
||||||
|
# example plugin
|
||||||
|
from cms.plugin_base import CMSPluginBase
|
||||||
|
|
||||||
|
class CMSCarouselPlugin(CMSPluginBase):
|
||||||
|
admin_preview = False
|
||||||
|
change_form_template = 'cms/sortable-stacked-inline-change-form.html'
|
||||||
|
inlines = [SlideInline]
|
||||||
|
model = Carousel
|
||||||
|
name = _('Carousel')
|
||||||
|
render_template = 'carousels/carousel.html'
|
||||||
|
|
||||||
|
def render(self, context, instance, placeholder):
|
||||||
|
context.update({
|
||||||
|
'carousel': instance,
|
||||||
|
'placeholder': placeholder
|
||||||
|
})
|
||||||
|
return context
|
||||||
|
|
||||||
|
plugin_pool.register_plugin(CMSCarouselPlugin)
|
||||||
|
|
||||||
|
The contents of sortable-stacked-inline-change-form.html at a minimum need to extend the extrahead block with::
|
||||||
|
|
||||||
|
{% extends "admin/cms/page/plugin_change_form.html" %}
|
||||||
|
{% load static from staticfiles %}
|
||||||
|
|
||||||
|
{% block extrahead %}
|
||||||
|
{{ block.super }}
|
||||||
|
<script type="text/javascript" src="{% static 'adminsortable/js/jquery-ui-django-admin.min.js' %}"></script>
|
||||||
|
<script type="text/javascript" src="{% static 'adminsortable/js/jquery.django-csrf.js' %}"></script>
|
||||||
|
<script type="text/javascript" src="{% static 'adminsortable/js/admin.sortable.stacked.inlines.js' %}"></script>
|
||||||
|
|
||||||
|
<link rel="stylesheet" type="text/css" href="{% static 'adminsortable/css/admin.sortable.inline.css' %}" />
|
||||||
|
{% endblock extrahead %}
|
||||||
|
|
||||||
|
Sorting within Django-CMS is really only feasible for inline models of a plugin as Django-CMS already includes sorting for plugin instances. For tabular inlines, just substitute::
|
||||||
|
|
||||||
|
<script type="text/javascript" src="{% static 'adminsortable/js/admin.sortable.stacked.inlines.js' %}"></script>
|
||||||
|
|
||||||
|
with::
|
||||||
|
|
||||||
|
<script type="text/javascript" src="{% static 'adminsortable/js/admin.sortable.tabular.inlines.js' %}"></script>
|
||||||
|
|
||||||
|
|
@ -0,0 +1,221 @@
|
||||||
|
|
||||||
|
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
|
||||||
|
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
|
||||||
|
<title>Django-CMS Integration — Django Admin Sortable 1.7.0 documentation</title>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<link href='https://fonts.googleapis.com/css?family=Lato:400,700,400italic,700italic|Roboto+Slab:400,700|Inconsolata:400,700' rel='stylesheet' type='text/css'>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<link rel="stylesheet" href="_static/css/theme.css" type="text/css" />
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<link rel="top" title="Django Admin Sortable 1.7.0 documentation" href="index.html"/>
|
||||||
|
<link rel="next" title="Testing" href="testing.html"/>
|
||||||
|
<link rel="prev" title="Using Django Admin Sortable" href="usage.html"/>
|
||||||
|
|
||||||
|
|
||||||
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/modernizr/2.6.2/modernizr.min.js"></script>
|
||||||
|
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body class="wy-body-for-nav" role="document">
|
||||||
|
|
||||||
|
<div class="wy-grid-for-nav">
|
||||||
|
|
||||||
|
|
||||||
|
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
|
||||||
|
<div class="wy-side-nav-search">
|
||||||
|
|
||||||
|
<a href="index.html" class="fa fa-home"> Django Admin Sortable</a>
|
||||||
|
|
||||||
|
<div role="search">
|
||||||
|
<form id ="rtd-search-form" class="wy-form" action="search.html" method="get">
|
||||||
|
<input type="text" name="q" placeholder="Search docs" />
|
||||||
|
<input type="hidden" name="check_keywords" value="yes" />
|
||||||
|
<input type="hidden" name="area" value="default" />
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
|
||||||
|
|
||||||
|
|
||||||
|
<ul class="current">
|
||||||
|
<li class="toctree-l1"><a class="reference internal" href="quickstart.html">Quickstart</a></li>
|
||||||
|
<li class="toctree-l1"><a class="reference internal" href="configuration.html">Configuring Django Admin Sortable</a><ul>
|
||||||
|
<li class="toctree-l2"><a class="reference internal" href="configuration.html#static-media">Static Media</a></li>
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
|
<li class="toctree-l1"><a class="reference internal" href="usage.html">Using Django Admin Sortable</a><ul>
|
||||||
|
<li class="toctree-l2"><a class="reference internal" href="usage.html#models">Models</a></li>
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
|
<li class="toctree-l1 current"><a class="current reference internal" href="">Django-CMS Integration</a></li>
|
||||||
|
<li class="toctree-l1"><a class="reference internal" href="testing.html">Testing</a></li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</nav>
|
||||||
|
|
||||||
|
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
|
||||||
|
|
||||||
|
|
||||||
|
<nav class="wy-nav-top" role="navigation" aria-label="top navigation">
|
||||||
|
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
|
||||||
|
<a href="index.html">Django Admin Sortable</a>
|
||||||
|
</nav>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<div class="wy-nav-content">
|
||||||
|
<div class="rst-content">
|
||||||
|
<div role="navigation" aria-label="breadcrumbs navigation">
|
||||||
|
<ul class="wy-breadcrumbs">
|
||||||
|
<li><a href="index.html">Docs</a> »</li>
|
||||||
|
|
||||||
|
<li>Django-CMS Integration</li>
|
||||||
|
<li class="wy-breadcrumbs-aside">
|
||||||
|
|
||||||
|
<a href="_sources/django-cms.txt" rel="nofollow"> View page source</a>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
<hr/>
|
||||||
|
</div>
|
||||||
|
<div role="main" class="document">
|
||||||
|
|
||||||
|
<div class="section" id="django-cms-integration">
|
||||||
|
<h1>Django-CMS Integration<a class="headerlink" href="#django-cms-integration" title="Permalink to this headline">¶</a></h1>
|
||||||
|
<p>Django-CMS plugins use their own change form, and thus won’t automatically include the necessary JavaScript for django-admin-sortable to work. Fortunately, this is easy to resolve, as the <code class="docutils literal"><span class="pre">CMSPlugin</span></code> class allows a change form template to be specified:</p>
|
||||||
|
<div class="highlight-python"><div class="highlight"><pre><span class="c"># example plugin</span>
|
||||||
|
<span class="kn">from</span> <span class="nn">cms.plugin_base</span> <span class="kn">import</span> <span class="n">CMSPluginBase</span>
|
||||||
|
|
||||||
|
<span class="k">class</span> <span class="nc">CMSCarouselPlugin</span><span class="p">(</span><span class="n">CMSPluginBase</span><span class="p">):</span>
|
||||||
|
<span class="n">admin_preview</span> <span class="o">=</span> <span class="bp">False</span>
|
||||||
|
<span class="n">change_form_template</span> <span class="o">=</span> <span class="s">'cms/sortable-stacked-inline-change-form.html'</span>
|
||||||
|
<span class="n">inlines</span> <span class="o">=</span> <span class="p">[</span><span class="n">SlideInline</span><span class="p">]</span>
|
||||||
|
<span class="n">model</span> <span class="o">=</span> <span class="n">Carousel</span>
|
||||||
|
<span class="n">name</span> <span class="o">=</span> <span class="n">_</span><span class="p">(</span><span class="s">'Carousel'</span><span class="p">)</span>
|
||||||
|
<span class="n">render_template</span> <span class="o">=</span> <span class="s">'carousels/carousel.html'</span>
|
||||||
|
|
||||||
|
<span class="k">def</span> <span class="nf">render</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">context</span><span class="p">,</span> <span class="n">instance</span><span class="p">,</span> <span class="n">placeholder</span><span class="p">):</span>
|
||||||
|
<span class="n">context</span><span class="o">.</span><span class="n">update</span><span class="p">({</span>
|
||||||
|
<span class="s">'carousel'</span><span class="p">:</span> <span class="n">instance</span><span class="p">,</span>
|
||||||
|
<span class="s">'placeholder'</span><span class="p">:</span> <span class="n">placeholder</span>
|
||||||
|
<span class="p">})</span>
|
||||||
|
<span class="k">return</span> <span class="n">context</span>
|
||||||
|
|
||||||
|
<span class="n">plugin_pool</span><span class="o">.</span><span class="n">register_plugin</span><span class="p">(</span><span class="n">CMSCarouselPlugin</span><span class="p">)</span>
|
||||||
|
</pre></div>
|
||||||
|
</div>
|
||||||
|
<p>The contents of sortable-stacked-inline-change-form.html at a minimum need to extend the extrahead block with:</p>
|
||||||
|
<div class="highlight-python"><div class="highlight"><pre>{% extends "admin/cms/page/plugin_change_form.html" %}
|
||||||
|
{% load static from staticfiles %}
|
||||||
|
|
||||||
|
{% block extrahead %}
|
||||||
|
{{ block.super }}
|
||||||
|
<script type="text/javascript" src="{% static 'adminsortable/js/jquery-ui-django-admin.min.js' %}"></script>
|
||||||
|
<script type="text/javascript" src="{% static 'adminsortable/js/jquery.django-csrf.js' %}"></script>
|
||||||
|
<script type="text/javascript" src="{% static 'adminsortable/js/admin.sortable.stacked.inlines.js' %}"></script>
|
||||||
|
|
||||||
|
<link rel="stylesheet" type="text/css" href="{% static 'adminsortable/css/admin.sortable.inline.css' %}" />
|
||||||
|
{% endblock extrahead %}
|
||||||
|
</pre></div>
|
||||||
|
</div>
|
||||||
|
<p>Sorting within Django-CMS is really only feasible for inline models of a plugin as Django-CMS already includes sorting for plugin instances. For tabular inlines, just substitute:</p>
|
||||||
|
<div class="highlight-python"><div class="highlight"><pre><script type="text/javascript" src="{% static 'adminsortable/js/admin.sortable.stacked.inlines.js' %}"></script>
|
||||||
|
</pre></div>
|
||||||
|
</div>
|
||||||
|
<p>with:</p>
|
||||||
|
<div class="highlight-python"><div class="highlight"><pre><script type="text/javascript" src="{% static 'adminsortable/js/admin.sortable.tabular.inlines.js' %}"></script>
|
||||||
|
</pre></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<footer>
|
||||||
|
|
||||||
|
<div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
|
||||||
|
|
||||||
|
<a href="testing.html" class="btn btn-neutral float-right" title="Testing">Next <span class="fa fa-arrow-circle-right"></span></a>
|
||||||
|
|
||||||
|
|
||||||
|
<a href="usage.html" class="btn btn-neutral" title="Using Django Admin Sortable"><span class="fa fa-arrow-circle-left"></span> Previous</a>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<hr/>
|
||||||
|
|
||||||
|
<div role="contentinfo">
|
||||||
|
<p>
|
||||||
|
© Copyright 2014, Brandon Taylor.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<a href="https://github.com/snide/sphinx_rtd_theme">Sphinx theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>
|
||||||
|
</footer>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</section>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
var DOCUMENTATION_OPTIONS = {
|
||||||
|
URL_ROOT:'./',
|
||||||
|
VERSION:'1.7.0',
|
||||||
|
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>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<script type="text/javascript" src="_static/js/theme.js"></script>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
jQuery(function () {
|
||||||
|
SphinxRtdTheme.StickyNav.enable();
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
@ -68,6 +68,7 @@
|
||||||
<li class="toctree-l2"><a class="reference internal" href="usage.html#models">Models</a></li>
|
<li class="toctree-l2"><a class="reference internal" href="usage.html#models">Models</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
|
<li class="toctree-l1"><a class="reference internal" href="django-cms.html">Django-CMS Integration</a></li>
|
||||||
<li class="toctree-l1"><a class="reference internal" href="testing.html">Testing</a></li>
|
<li class="toctree-l1"><a class="reference internal" href="testing.html">Testing</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -68,6 +68,7 @@
|
||||||
<li class="toctree-l2"><a class="reference internal" href="usage.html#models">Models</a></li>
|
<li class="toctree-l2"><a class="reference internal" href="usage.html#models">Models</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
|
<li class="toctree-l1"><a class="reference internal" href="django-cms.html">Django-CMS Integration</a></li>
|
||||||
<li class="toctree-l1"><a class="reference internal" href="testing.html">Testing</a></li>
|
<li class="toctree-l1"><a class="reference internal" href="testing.html">Testing</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
|
@ -144,6 +145,7 @@
|
||||||
<li class="toctree-l2"><a class="reference internal" href="usage.html#models">Models</a></li>
|
<li class="toctree-l2"><a class="reference internal" href="usage.html#models">Models</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
|
<li class="toctree-l1"><a class="reference internal" href="django-cms.html">Django-CMS Integration</a></li>
|
||||||
<li class="toctree-l1"><a class="reference internal" href="testing.html">Testing</a></li>
|
<li class="toctree-l1"><a class="reference internal" href="testing.html">Testing</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -67,6 +67,7 @@
|
||||||
<li class="toctree-l2"><a class="reference internal" href="usage.html#models">Models</a></li>
|
<li class="toctree-l2"><a class="reference internal" href="usage.html#models">Models</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
|
<li class="toctree-l1"><a class="reference internal" href="django-cms.html">Django-CMS Integration</a></li>
|
||||||
<li class="toctree-l1"><a class="reference internal" href="testing.html">Testing</a></li>
|
<li class="toctree-l1"><a class="reference internal" href="testing.html">Testing</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
Search.setIndex({envversion:42,terms:{serv:2,all:0,code:0,anticip:0,text:0,over:0,veri:0,through:1,file:[2,3],follow:0,entequak:1,dynam:0,previous:0,categori:0,componentinlin:0,group:[0,1],thank:1,easi:1,field:0,should:4,add:[0,1,2,4],title__icontain:0,board:0,onc:0,els:0,folder:2,save:0,adminsort:[0,2,4],app:[2,3],introduc:[0,1],custom:3,them:0,"return":[0,4],get:[2,4],python:[1,3],util:0,context_processor:[2,4],is_board_memb:0,"import":[0,4],increas:0,now:4,is_sort:0,tbd:[],requir:0,template_context_processor:[2,4],enabl:[0,1],anyth:0,drop:[1,3,4],list:0,last_nam:0,staticfil:2,item:1,enumer:0,either:0,each:0,small:0,found:3,updat:1,where:[3,4],manag:[1,3],view:[0,3,4],pleas:1,set:[0,4],sortableadmin:[0,4],person:0,individu:1,some:0,sortablegenerictabularinlin:0,ensur:[2,4],see:[0,3],meta:[0,4],sampl:0,pass:[0,4],click:3,special:0,page:1,compat:1,index:[0,1],wire:4,insid:2,defin:[0,4],mysortabletabularinlin:0,abl:0,content:[],won:0,unit:3,rel:0,"new":[],foo:0,method:[0,2],note:0,attribut:[0,1],altern:2,core:[2,4],javascript:[0,2],run:3,parent:0,migrat:0,gener:0,sortabletabularinlin:0,here:[0,4],standard:0,base:[0,1],symlink:2,dictionari:0,few:[0,2],depend:0,"super":[0,1],valu:0,addit:0,search:1,wai:[0,1],change_form_template_extend:0,befor:0,column:0,latest:1,verbose_name_plur:0,filter:0,orm:0,includ:[0,2,3],fals:0,charfield:[0,4],chang:[0,1,3],sortablestackedinlin:0,honor:0,south:0,via:3,simpli:4,directli:3,extra:[0,4],instanti:0,appli:0,modul:1,independ:0,prefer:2,number:0,automat:0,due:0,change_form:0,right:0,contrib:0,instal:4,installed_app:[2,4],assum:0,your:[0,1,2,4],select:0,login:3,"class":[0,4],quit:2,from:[0,2,3,4],would:0,area:3,data:0,regist:[0,4],sometim:0,name:0,compon:0,start:4,max_length:[0,4],"__unicode__":[0,4],recommend:0,taken:3,inner:0,locat:2,tabularinlin:0,"function":3,properli:0,desir:4,option:[0,4],form:[0,3],ascend:0,tool:[3,4],copi:2,about:0,specifi:0,site:[0,4],forward:0,link:[0,3,4],tabularstackedinlin:0,line:0,inlin:[1,3],"true":0,present:[0,4],must:0,"case":0,anoth:0,made:1,look:[0,3],possibl:0,"default":0,directori:[2,3],change_list:0,displai:0,project:[0,2,3,4],record:3,below:[0,1],can:[0,2,3,4],caveat:0,foreignkei:0,"static":4,schema:0,booleanfield:0,def:[0,4],sort:[],sai:3,myapp:0,creat:0,quickstart:[],almost:1,credenti:3,changelist:4,sortablegenericstackedinlin:0,non:0,tabular:0,need:[0,4],inform:0,inherit:[0,4],have:[0,3,4],pip:4,mysortableadminclass:[0,4],work:[0,3],edit_inlin:0,normal:0,hit:0,incompat:[0,1],mysortableclass:[0,4],equival:0,get_is_sort:0,suggest:0,self:[0,4],format:[0,1],when:[3,4],same:0,member:0,also:[0,1],html:0,take:4,which:0,tupl:[0,1],test:[],instead:0,you:[0,1,2,3,4],properti:0,simpl:2,css:[0,2],difficult:0,mysortablestackedinlin:0,get_queryset:0,allow:0,stackedinlin:0,sorting_filt:[0,1],positivesmallinteg:0,why:0,after:0,director:0,peopl:0,drag:[1,3,4],two:0,thi:[0,3],mai:[0,1,3],change_list_template_extend:0,stack:0,appear:0,exactli:0,appropri:0,don:0,first_nam:0,ani:[0,1,3,4],widgetadmin:0,request:0,object:4,order:[0,1,3,4],height:0,more:[0,4],sample_project:3,exampl:0,determin:0,titl:[0,4],tall:0,model:[3,4],backward:[0,1],make:0,provid:0,left:0},objtypes:{},objnames:{},filenames:["usage","index","configuration","testing","quickstart"],titles:["Using Django Admin Sortable","Welcome to Django Admin Sortable’s documentation!","Configuring Django Admin Sortable","Testing","Quickstart"],objects:{},titleterms:{overrid:0,subset:0,quickstart:4,queryset:0,indic:1,exist:0,tabl:1,what:1,welcom:1,media:2,support:1,configur:2,custom:0,content:1,version:1,test:3,"new":1,document:1,higher:[],sort:0,sortabl:[0,1,2],extend:0,object:0,templat:0,inlin:0,admin:[0,1,2],django:[0,1,2],integr:0,"static":2,model:0}})
|
Search.setIndex({envversion:42,terms:{all:4,code:4,just:3,anticip:4,text:[4,3],over:4,plugin_bas:3,veri:4,via:2,through:0,left:4,follow:4,line:4,dynam:4,previous:4,content:[],onli:3,componentinlin:4,group:[4,0],thank:0,easi:[0,3],cmscarouselplugin:3,cmspluginbas:3,should:1,add:[4,0,5,1],html:[4,3],title__icontain:4,board:4,appli:4,els:4,folder:5,save:4,adminsort:[4,3,1,5],modul:0,introduc:[4,0],take:1,"case":4,them:4,independ:4,"return":[4,3,1],member:4,get:[5,1],python:[0,2],hit:4,util:4,context_processor:[5,1],is_board_memb:4,csrf:3,"new":[],increas:4,cmsplugin:3,is_sort:4,tbd:[],requir:4,template_context_processor:[5,1],change_form_templ:3,enabl:[4,0],anyth:4,drop:[0,2,1],list:4,last_nam:4,staticfil:[3,5],item:0,enumer:4,necessari:3,either:4,have:[4,2,1],each:4,small:4,found:2,difficult:4,where:[2,1],page:[0,3],view:[4,2,1],pleas:0,set:[4,1],fortun:3,individu:0,some:4,sortablegenerictabularinlin:4,contrib:4,see:[4,2],meta:[4,1],sampl:4,now:1,pass:[4,1],slideinlin:3,stack:[4,3],click:2,special:4,after:4,compat:0,index:[4,0],wire:1,appear:4,record:2,mysortabletabularinlin:4,abl:4,work:[4,2,3],categori:4,substitut:3,won:[4,3],select:4,rel:[4,3],"import":[4,3,1],foo:4,method:[4,5],attribut:[4,0],altern:5,core:[5,1],sortabletabularinlin:4,run:2,insid:5,migrat:4,resolv:3,gener:4,javascript:[4,3,5],here:[4,1],standard:4,base:[4,0],symlink:5,dictionari:4,depend:4,widgetadmin:4,"super":[4,0,3],"__unicode__":[4,1],render_templ:3,src:3,search:0,would:4,change_form_template_extend:4,plugin:3,column:4,extrahead:3,area:2,manag:[0,2],filter:4,instanc:3,includ:[4,2,5,3],context:3,fals:[4,3],charfield:[4,1],chang:[4,0,2,3],sortablestackedinlin:4,honor:4,south:4,load:3,schema:4,own:3,simpli:1,directli:2,extra:[4,1],instanti:4,onc:4,app:[2,5],within:3,prefer:5,number:4,automat:[4,3],placehold:3,order:[4,0,2,1],ascend:4,change_form:4,href:3,non:4,orm:4,ensur:[5,1],sortableadmin:[4,1],installed_app:[5,1],assum:4,your:[4,0,5,1],unit:2,quickstart:[],register_plugin:3,quit:5,from:[4,5,2,1,3],object:1,wai:[4,0],script:3,anoth:4,change_list_template_extend:4,regist:[4,1],due:4,custom:2,compon:4,few:[4,5],stylesheet:3,max_length:[4,1],valu:4,carousel:3,recommend:4,taken:2,inner:4,addit:4,instal:1,start:1,tabularinlin:4,"function":2,project:[4,2,1,5],properli:4,desir:1,option:[4,1],name:[4,3],peopl:4,tool:[2,1],copi:5,about:4,specifi:[4,3],site:[4,1],forward:4,link:[4,2,1,3],def:[4,3,1],tabularstackedinlin:4,alreadi:3,entequak:0,realli:3,"true":4,present:[4,1],must:4,serv:5,also:[4,0],made:0,sometim:4,possibl:4,"default":4,type:3,determin:4,change_list:4,displai:4,jqueri:3,defin:[4,1],below:[4,0],can:[4,2,1,5],caveat:4,foreignkei:4,"static":1,inform:4,more:[4,1],booleanfield:4,endblock:3,sort:[],sai:2,file:[2,5],creat:4,look:[4,2],almost:0,request:4,changelist:1,sortablegenericstackedinlin:4,ani:[4,0,2,1],tabular:[4,3],pip:1,befor:4,minimum:3,right:4,myapp:4,need:[4,3,1],mysortableadminclass:[4,1],verbose_name_plur:4,edit_inlin:4,parent:4,incompat:[4,0],form:[4,2,3],equival:4,get_is_sort:4,suggest:4,inlin:2,format:[4,0],when:[2,1],same:4,note:4,field:4,make:4,stackedinlin:4,plugin_pool:3,which:4,tupl:[4,0],test:[],instead:4,you:[4,0,2,1,5],properti:4,simpl:5,css:[4,3,5],updat:[0,3],mysortablestackedinlin:4,get_queryset:4,allow:[4,3],normal:4,sorting_filt:[4,0],positivesmallinteg:4,why:4,plugin_change_form:3,director:4,"class":[4,3,1],drag:[0,2,1],two:4,tall:4,mai:[4,0,2],data:4,login:2,mysortableclass:[4,1],exactli:4,appropri:4,don:4,first_nam:4,feasibl:3,directori:[2,5],thu:3,min:3,credenti:2,inherit:[4,1],locat:5,height:4,person:4,sample_project:2,exampl:[4,3],block:3,thi:[4,2,3],titl:[4,1],admin_preview:3,model:[2,1],backward:[4,0],render:3,self:[4,3,1],provid:4,latest:0},objtypes:{},objnames:{},filenames:["index","quickstart","testing","django-cms","usage","configuration"],titles:["Welcome to Django Admin Sortable’s documentation!","Quickstart","Testing","Django-CMS Integration","Using Django Admin Sortable","Configuring Django Admin Sortable"],objects:{},titleterms:{overrid:4,subset:4,quickstart:1,queryset:4,indic:0,exist:4,tabl:0,what:0,welcom:0,media:5,support:0,configur:5,custom:4,content:0,version:0,test:2,"new":0,document:0,higher:[],sort:4,sortabl:[4,0,5],extend:4,object:4,templat:4,inlin:4,admin:[4,0,5],django:[4,0,3,5],integr:[4,3],"static":5,model:4}})
|
||||||
|
|
@ -0,0 +1,47 @@
|
||||||
|
Django-CMS Integration
|
||||||
|
======================
|
||||||
|
|
||||||
|
Django-CMS plugins use their own change form, and thus won't automatically include the necessary JavaScript for django-admin-sortable to work. Fortunately, this is easy to resolve, as the ``CMSPlugin`` class allows a change form template to be specified::
|
||||||
|
|
||||||
|
# example plugin
|
||||||
|
from cms.plugin_base import CMSPluginBase
|
||||||
|
|
||||||
|
class CMSCarouselPlugin(CMSPluginBase):
|
||||||
|
admin_preview = False
|
||||||
|
change_form_template = 'cms/sortable-stacked-inline-change-form.html'
|
||||||
|
inlines = [SlideInline]
|
||||||
|
model = Carousel
|
||||||
|
name = _('Carousel')
|
||||||
|
render_template = 'carousels/carousel.html'
|
||||||
|
|
||||||
|
def render(self, context, instance, placeholder):
|
||||||
|
context.update({
|
||||||
|
'carousel': instance,
|
||||||
|
'placeholder': placeholder
|
||||||
|
})
|
||||||
|
return context
|
||||||
|
|
||||||
|
plugin_pool.register_plugin(CMSCarouselPlugin)
|
||||||
|
|
||||||
|
The contents of sortable-stacked-inline-change-form.html at a minimum need to extend the extrahead block with::
|
||||||
|
|
||||||
|
{% extends "admin/cms/page/plugin_change_form.html" %}
|
||||||
|
{% load static from staticfiles %}
|
||||||
|
|
||||||
|
{% block extrahead %}
|
||||||
|
{{ block.super }}
|
||||||
|
<script type="text/javascript" src="{% static 'adminsortable/js/jquery-ui-django-admin.min.js' %}"></script>
|
||||||
|
<script type="text/javascript" src="{% static 'adminsortable/js/jquery.django-csrf.js' %}"></script>
|
||||||
|
<script type="text/javascript" src="{% static 'adminsortable/js/admin.sortable.stacked.inlines.js' %}"></script>
|
||||||
|
|
||||||
|
<link rel="stylesheet" type="text/css" href="{% static 'adminsortable/css/admin.sortable.inline.css' %}" />
|
||||||
|
{% endblock extrahead %}
|
||||||
|
|
||||||
|
Sorting within Django-CMS is really only feasible for inline models of a plugin as Django-CMS already includes sorting for plugin instances. For tabular inlines, just substitute::
|
||||||
|
|
||||||
|
<script type="text/javascript" src="{% static 'adminsortable/js/admin.sortable.stacked.inlines.js' %}"></script>
|
||||||
|
|
||||||
|
with::
|
||||||
|
|
||||||
|
<script type="text/javascript" src="{% static 'adminsortable/js/admin.sortable.tabular.inlines.js' %}"></script>
|
||||||
|
|
||||||
Loading…
Reference in New Issue