djangosnippets.org: Latest snippets tagged with 'commands'https://djangosnippets.org/tags/commands/2018-09-10T22:55:02.834174-05:00create custom permissions
2018-09-10T22:55:02.834174-05:00agusmakmunhttps://djangosnippets.org/snippets/10653/<p>create custom permissions</p>
Freely redistributableManagement command which helps to find temlate files
2011-01-05T12:24:39.341022-06:00skyjurhttps://djangosnippets.org/snippets/2308/<p>If you need to customize many default templates from installed apps, this management command will help you to find those templates and to copy them to desired location.
</p>
<p>Place this code at:
</p>
<pre><code>management/commands/templates.py
</code></pre><p>To see a list of installed templates, run:
</p>
<pre><code>python manage.py templates
</code></pre><p>To copy all templates to specified …</p>
Freely redistributableContinuous Integration command
2009-10-17T11:47:54.470794-05:00bertohttps://djangosnippets.org/snippets/1763/<p>This command, <code>runtester</code> will run the test suite whenever files are modified. It takes the apps to test as arguments; if no apps are given the entire test suite is run.
</p>
<p>Use this command just as <code>runserver</code> is used; fire it up in a shell and it does its thing. …</p>
Freely redistributableCustom management command to list recent admin actions
2009-07-16T21:55:20.343417-05:00pbxhttps://djangosnippets.org/snippets/1637/<p>On a busy site it can be nice to have a summary of admin activity. Running this command (I call it "adminlog") generates output like this:</p>
<pre><code>2009-07-10 18:06:19: pbx changed flat page: "/yay/ -- Let's All Say Yay"
</code></pre>
<p>By default it shows the last five actions; pass it a numerical …</p>
Freely redistributableManagement command to list custom management commands
2009-06-11T10:17:09.180007-05:00pbxhttps://djangosnippets.org/snippets/1564/<p>I work with multiple projects, many of which have multiple custom management commands defined. It can be hard to remember them, and slow to pick them out of the "manage.py help" list. </p>
<p>This quickie command lists all of a project's custom commands (along with their help text). Writing it was …</p>
Freely redistributablesyncdata command
2008-07-29T18:02:57.781718-05:00grahamhttps://djangosnippets.org/snippets/926/<p>A django admin command that takes a fixture and makes the target database the same as that fixture, deleting objects that in the database but not in the fixture, updating objects that are different in the database, and inserting missing ones.
Place this code in your_app/management/commands/syncdata.py
You will need to …</p>
Freely redistributableCommand to make fixtures.
2008-07-27T03:36:06.861738-05:00buriyhttps://djangosnippets.org/snippets/918/<p>"Make fixture" command. Highly useful for making test fixtures.
Use it to pick only few items from your data to serialize, restricted by primary keys.
By default command also serializes foreign keys and m2m relations.
You can turn off related items serialization with <code>--skip-related</code> option.
</p>
<p>How to use:
</p>
<pre><code>python manage.py …</code></pre>
Freely redistributableCommand to dump data as a python script
2008-06-20T12:26:34.864746-05:00willhardyhttps://djangosnippets.org/snippets/818/<p>This creates a fixture in the form of a python script.</p>
<p>Handles:</p>
<ol>
<li><code>ForeignKey</code> and <code>ManyToManyField</code>s (using python variables, not IDs)</li>
<li>Self-referencing <code>ForeignKey</code> (and M2M) fields</li>
<li>Sub-classed models</li>
<li><code>ContentType</code> fields</li>
<li>Recursive references</li>
<li><code>AutoField</code>s are excluded</li>
<li>Parent models are only included when no other child model links to it</li>
</ol>
<p>There …</p>
Freely redistributableextras.py for management commands
2007-08-22T09:37:48.824325-05:00dnordberghttps://djangosnippets.org/snippets/380/<p>! Note - no longer needed </p>
<p>Save this script in the same directory as manage.py and run it through the command line.</p>
<p>It picks up project Command class instances. Something that will hopefully be fixed in the Django SVN version soon.</p>
<p>Heres an example of a command:</p>
<h1>utils/management/commands/sqlallall.py</h1>
<p>from django.core.management …</p>
Freely redistributable