djangosnippets.org: Latest snippets posted by karolyihttps://djangosnippets.org/users/karolyi/2018-10-12T11:13:54.203739-05:00karolyiHand over model instance relations to another instance of the same model
2018-10-12T11:13:54.203739-05:00karolyihttps://djangosnippets.org/snippets/10654/<p>If you have a model instance you want to merge into another, it's handy to hand over all the relations into the model you want to merge into, so the deletion won't trigger cascading deletions from other tables.</p>
<p>You can pass an <code>Iterable</code> of the same objects (a.k.a <code>QuerySet</code>) …</p>
Freely redistributableEllipsis paginator decorator with first and last two items
2015-10-23T15:23:32.571887-05:00karolyihttps://djangosnippets.org/snippets/10535/<p>Use this template tag to get a paginator showing the first and last two pages w/ adjacent pages using ellipsis.</p>
<p>The <code>page</code> parameter is a page of a <code>Paginator</code> (typically the first but you can use whichever you want).</p>
<p>In case of 50 pages, while being on the 40th, it'll …</p>
Freely redistributableSmart wrapping Django admin's delete_selected
2015-10-23T15:06:06.037245-05:00karolyihttps://djangosnippets.org/snippets/10534/<p>The idea here is to wrap the original <code>delete_selected</code> functionality in a way that I shouldn't have to reimplement the templates (confirmation/error response) serving, just extend the original.</p>
<p>What this code does, it wraps the queryset's delete function with a closure, so when it really gets called (after the confirmation), …</p>
Freely redistributable