"Magic Link" Management Command
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.
- authentication
- magic
- management
- command
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.
With this command you can calculate the maintainability index for your whole project. In your settings you have to add a dictionary called `RADON_MI_SETTINGS`. It could be like this: ```python RADON_MI_SETTINGS = { 'paths': ['projectname'], 'exclude': 'projectname/some_app/some_file.py', 'ignore': 'migrations,tests', } ``` I had to add following packages: ``` radon==3.0.1 progress==1.5 plotly==3.7.0 GitPython==2.1.11 ``` Following commands are available: * `python manage.py calculate_maintainability_index` Only display the maintainability index of the project. The average from every file is build by using the logical lines of code per file. * `python manage.py calculate_maintainability_index --init` Go through every commit filtered by their commit_message (is set to “bump version” currently) and calculate the maintainability index for the whole project. This creates a file with the history. * `python manage.py calculate_maintainability_index --showhistory` Display the history of the maintainability_index in a graph in your browser. * `python manage.py calculate_maintainability_index --commit` Calculate the current maintainability_index and append it to your history. Commit your edited history file. * `python manage.py calculate_maintainability_index --fail` Calculate the current maintainability_index and raise an Error, if it is lower than the last entry in your history. Useful for use in an automated pipeline. Hints: * radon has a problem with large lists and dictionaries. If you have a file with a list or dictionary with more than 100 entries, you should exclude it. * To initialize your history you should change the commitmessage filter to something, that suits your needs. Created by Martin Becker at [Jonas und der Wolf GmbH](https://www.jonasundderwolf.de)
add comment "# coding:utf8# to all python file
Inspired and based on https://djangosnippets.org/snippets/918/ Improvements: - Supports natural keys - Uses Django's Collector so hopefully follows reverse relationships - Fixes problem when you don't specify a slice - PEP8 etc.
..
Add this to any app as a custom management command.
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. Place this code at: management/commands/templates.py To see a list of installed templates, run: python manage.py templates To copy all templates to specified location: python manage.py templates --copy-to ./templates To copy templates from specified applications only: python manage.py templates admin auth --copy-to ./templates
example of use: 1. python manage.py yuml yourapp yoursecondapp --scruffy -s 75 -o test.png 2. python manage.py yuml justoneapp --scruffy -o test.pdf 3. generate whole project yuml : python manage.py yuml -a -o test.jpg 4. python manage.py yuml auth contenttypes sessions admin -o test.pdf [github repository](http://github.com/dzhibas/django-yuml)
launch python manage.py yourcommand and command output paste into http://www.yuml.me/diagram/scruffy/class/draw todo: 1.implement other relation attributes 2.add class inheritance 3.download image automatically 4.generate diagram for specific app
Just like it says -- set it up and run. Use it for server migrations, for project handoffs, in cron jobs, you name it. 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 impossible-triangle of OneToOneField dependencies anyway, and they were going from a sqlite file to a postgres schema that totally had inappropriate nullable columns in it). I find that the json files named for what they contain is helpful when and if manage.py does freak out during an import, as the output from `loaddata` command is so opaque it's autistic, basically. A trivial refactoring effort could make it into a management command -- it already makes use of the builtin `dumpdata` command class internally. However I did not feel like overthinking it enough to set it up in a repository (doubtlessly padded with unrelated 'utilities' and explanatory .rst files) and then writing a blog post to sell it to you. That is why you are reading this code here, instead of on GitHub. Don't get me wrong, GitHub is awesome, and like a consummate host... but not the way I love me some quick and dirty snippet code, these days. Whatever, you say lazy, I say productively relaxed, potato/potahto. Erm. In any case please do enjoy this model fixture-exporter. Yes.
A quick-and-dirty, and extremely simple, decorator to turn a simple function into a management command. 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. The function's docstring will be used for the command's help text if the `help` arg is not passed to the decorator. Simple usage: from myapp.utils import command @command() def my_command(): print "Hello, world" I'm not too familiar with the intricacies of decorators and management commands, so this could probably (most likely) be improved upon, but it's a start. **Update**: I've taken this a bit farther and put my work up on bitbucket: https://bitbucket.org/eternicode/django-management-decorators/src
Generate model data with this django management command! 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. You can supply quite a few parameters that control how the data is generated. And you can control it per field, per model. Or you can supply your own callable function which you can return your own random data. **SEE THE DOCS / EXAMPLE IN THE CODE SNIPPET FOR AVAILABLE OPTIONS, AND HOW TO CONTROL GENERATED DATA PARAMETERS** You can generate data that looks like real content, without having to write fixtures and such. Just generate it! It can generate data for these types of fields: EmailField SlugField BooleanField DateField DateTimeField TimeField IntegerField DecimalField TextField CharField IPAddressField URLField SmallIntegerField PositiveSmallIntegerField PositiveIntegerField ImageField There are also a few callables included that you can use to generate this kind of data: zip, extended zip, hashkey and uuid It's also worth noting that I keep this project up to date on my own git repository. There are a few fonts you'll need if you want to generate imaages, included in my git repo. http://gitweb.codeendeavor.com/?p=dilla.git;a=summary
Modifies the as_sql methods to print the queries.
This command, `runtester` 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. Use this command just as `runserver` is used; fire it up in a shell and it does its thing. Copy this snippet into `django/core/management/commands/runtester.py`.
This adds an 'fbshell' management command which starts up a Python shell with an authenticated [pyfacebook](http://code.google.com/p/pyfacebook/) instance ready to make requests. This is very useful for testing out facebook requests or performing administration tasks without hooking a debugger into your application. This snippet should be saved to /yourproject/management/commands/fbshell.py See [custom management commands](http://docs.djangoproject.com/en/dev/howto/custom-management-commands/) for a description of how this works. If you are already using pyfacebook in your app then you'll already have the right settings, so just run : $ python manage.py fbshell A browser window will pop up, prompting you for authentication (unless you're already logged in to facebook). Press enter in the shell when you're finished this, and you'll be dropped into a shell with the session key, uuid, and name printed. Now you can use the facebook instance: >>> facebook.friends.get() >>> [...] If you haven't used pyfacebook in your app, you'll need at least the following settings in your settings.py FACEBOOK_API_KEY = 'your_api_key' FACEBOOK_SECRET_KEY = 'your_secret_key'
24 snippets posted so far.