djangosnippets.org: Latest snippets tagged with 'command'http://djangosnippets.org/tags/command/2021-03-24T08:52:02.850184-05:00"Magic Link" Management Command
2021-03-24T08:52:02.850184-05:00webologyhttp://djangosnippets.org/snippets/10855/<p>Django Management Command to print a "Magic Link" for one-click log-in. This is nice for people who project switch or don't want to remember passwords.</p>
Freely redistributableCalculating Maintainability Index for a whole project
2019-04-18T08:43:18.039984-05:00MrtnBckrhttp://djangosnippets.org/snippets/10665/<p>With this command you can calculate the maintainability index for your whole project. </p>
<p>In your settings you have to add a dictionary called <code>RADON_MI_SETTINGS</code>. It could be like this: </p>
<p><code>python
RADON_MI_SETTINGS = {
'paths': ['projectname'],
'exclude': 'projectname/some_app/some_file.py',
'ignore': 'migrations,tests',
}</code></p>
<p>I had to add following packages:
<code>radon==3.0.1
progress==1.5
plotly==3.7.0 …</code></p>
Freely redistributableadd encoding comment to project all python file
2017-10-09T01:58:17.332616-05:00liaobaochenghttp://djangosnippets.org/snippets/10626/<p>add comment "# coding:utf8# to all python file</p>
Freely redistributableMake fixtures and follow relationships.
2015-07-01T12:21:22.652250-05:00andybakhttp://djangosnippets.org/snippets/10506/<p>Inspired and based on https://djangosnippets.org/snippets/918/</p>
<p>Improvements:</p>
<ul>
<li>Supports natural keys</li>
<li>Uses Django's Collector so hopefully follows reverse relationships</li>
<li>Fixes problem when you don't specify a slice</li>
<li>PEP8 etc.</li>
</ul>
Freely redistributableClean spam from comments by running management command and akismet
2012-10-20T17:49:27.612326-05:00iElectrichttp://djangosnippets.org/snippets/2835/<p>..</p>
Freely redistributableCustom Command for Rebuilding Permissions and ContentTypes
2011-03-21T19:01:33.359897-05:00cronosahttp://djangosnippets.org/snippets/2398/<p>Add this to any app as a custom management command. </p>
Freely redistributableManagement command which helps to find temlate files
2011-01-05T12:24:39.341022-06:00skyjurhttp://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 redistributableImproved command to generate UML diagrams of whole project or specified apps
2010-10-07T04:51:00.717143-05:00nikolajuskhttp://djangosnippets.org/snippets/2225/<p>example of use:
</p>
<ol>
<li><p>python manage.py yuml yourapp yoursecondapp --scruffy -s 75 -o test.png
</p>
</li>
<li><p>python manage.py yuml justoneapp --scruffy -o test.pdf
</p>
</li>
<li><p>generate whole project yuml : python manage.py yuml -a -o test.jpg
</p>
</li>
<li><p>python manage.py yuml auth contenttypes sessions admin -o test.pdf
</p>
</li>
</ol>
<p><a href="http://github.com/dzhibas/django-yuml">github repository</a>
</p>
Freely redistributableSimple snippet to generate whole project models uml diagram in YUML.me format
2010-10-06T10:06:51.519223-05:00nikolajuskhttp://djangosnippets.org/snippets/2222/<p>launch python manage.py yourcommand
and command output paste into http://www.yuml.me/diagram/scruffy/class/draw
</p>
<p>todo:
1.implement other relation attributes
2.add class inheritance
3.download image automatically
4.generate diagram for specific app
</p>
Freely redistributableExport Django data to datestamped tarball -- choose individual models for handy packaging and archiving
2010-09-23T05:52:25.978241-05:00fish2000http://djangosnippets.org/snippets/2203/<p>Just like it says -- set it up and run. Use it for server migrations, for project handoffs, in cron jobs, you name it.
</p>
<p>I have never had problems exporting models to individual fixtures in this way, and only one bout of trouble re-importing them (and that was, like, an …</p>
Freely redistributableManagement command decorator
2010-08-31T10:43:39.491519-05:00eternicodehttp://djangosnippets.org/snippets/2181/<p>A quick-and-dirty, and extremely simple, decorator to turn a simple function into a management command.
</p>
<p>This still requires you to have the management directory structure, but allows you to name your primary method whatever you want, and encapsulates the basic functionality of an argument-accepting management commmand.
</p>
<p>The function's docstring will …</p>
Freely redistributableGenerate Model Data. Lots of Options.
2010-03-25T02:14:13.741665-05:00bl4th3rsk1t3http://djangosnippets.org/snippets/1969/<p>Generate model data with this django management command!
</p>
<p>Data is generated based off of the model field types. And will also correctly generate foreign key's to other randomly generated records for join tables. And generate images with random colors and random words in the image - for image fields.
</p>
<p>You …</p>
Freely redistributableprint SQL statements
2010-02-09T15:34:49.379511-06:00zuzelvphttp://djangosnippets.org/snippets/1917/<p>Modifies the as_sql methods to print the queries.
</p>
Freely redistributableContinuous Integration command
2009-10-17T11:47:54.470794-05:00bertohttp://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 redistributableFacebook shell
2009-09-04T07:57:21.134871-05:00stephenemsliehttp://djangosnippets.org/snippets/1716/<p>This adds an 'fbshell' management command which starts up a Python shell with an authenticated <a href="http://code.google.com/p/pyfacebook/">pyfacebook</a> instance ready to make requests.</p>
<p>This is very useful for testing out facebook requests or performing administration tasks without hooking a debugger into your application.</p>
<p>This snippet should be saved to </p>
<pre><code>/yourproject/management/commands/fbshell.py
</code></pre>
<p>See <a href="http://docs.djangoproject.com/en/dev/howto/custom-management-commands/">custom …</a></p>
Freely redistributable