snipt

Ctrl+h for KB shortcuts

Text only

Django tip from StackOverflow

1
2
3
4
5
6
Install Django Command Extensions and pygraphviz and then issue the following command to get a really nice looking Django model visualization:

./manage.py graph_models -a -g -o my_project.png

See the rest here:
http://stackoverflow.com/questions/550632/favorite-django-tips-features
https://snipt.net/embed/d4d40e12173ab323b2dfbb1c8d1359e6/
/raw/d4d40e12173ab323b2dfbb1c8d1359e6/
d4d40e12173ab323b2dfbb1c8d1359e6
text
Text only
6
2019-05-29T14:07:48
True
False
False
/api/public/snipt/6475/
django-tip-from-stackoverflow
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a> <a href="#L-5">5</a> <a href="#L-6">6</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a>Install Django Command Extensions and pygraphviz and then issue the following command to get a really nice looking Django model visualization: </span><span id="L-2"><a name="L-2"></a> </span><span id="L-3"><a name="L-3"></a>./manage.py graph_models -a -g -o my_project.png </span><span id="L-4"><a name="L-4"></a> </span><span id="L-5"><a name="L-5"></a>See the rest here: </span><span id="L-6"><a name="L-6"></a>http://stackoverflow.com/questions/550632/favorite-django-tips-features </span></pre></div> </td></tr></table>
django

Django/Jinja

Iterate over a dict in a Django template

{% for key,value in dictionary.items %}{{ value }}{% endfor %}
https://snipt.net/embed/bddb1ace7b9a1ebc0a171afc7190704b/
/raw/bddb1ace7b9a1ebc0a171afc7190704b/
bddb1ace7b9a1ebc0a171afc7190704b
django
Django/Jinja
1
2019-06-08T03:23:47
True
False
False
/api/public/snipt/6334/
iterate-over-a-dict-in-a-django-template
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="cp">{%</span> <span class="k">for</span> <span class="nv">key</span><span class="o">,</span><span class="nv">value</span> <span class="k">in</span> <span class="nv">dictionary.items</span> <span class="cp">%}{{</span> <span class="nv">value</span> <span class="cp">}}{%</span> <span class="k">endfor</span> <span class="cp">%}</span><span class="x"></span> </span></pre></div> </td></tr></table>
django